output to file different than console. (ssh and zfs )

Johan Hendriks joh.hendriks at gmail.com
Thu Mar 10 18:12:55 UTC 2016


Hello all.

I use a script to get a list of snapshots from a remote machine.

If I run it on the console it gives me the following.

root at storage1:/ # ssh root at storage2.server.mydomain.com /sbin/zfs list
-H -o name -t snapshot | grep 15min_ | sort
storage/home/datadir1 at 15min_2016-03-09_22.20.00--1h
storage/home/datadir2 at 15min_2016-03-09_22.20.00--1h
storage/home/datadir3 at 15min_2016-03-09_22.20.00--1h
storage/home/datadir4 at 15min_2016-03-09_22.20.00--1h
root at storage1:/ #

As you see the output shows the zfs snapshots of the remote server. I
need this to to into a file so I can grep, sed and do other things with it.
If I put the output to a file than the name of the remote machine is in
that file. ( I see this on my 10.2 machines, not on my 9.x machines.)

root at storage1:/ # ssh root at storage2.server.mydomain.com /sbin/zfs list
-H -o name -t snapshot | grep 15min_ | sort > /tmp/zfs-remote-snapshot
root at storage1:/ # vi /tmp/zfs-remote-snapshot

^[]0;storage2.server.mydomain.com^Gstorage/home/datadir1 at 15min_2016-03-09_22.20.00--1h
storage/home/datadir2 at 15min_2016-03-09_22.20.00--1h
storage/home/datadir3 at 15min_2016-03-09_22.20.00--1h
storage/home/datadir4 at 15min_2016-03-09_22.20.00--1h

I have no idea why the hostname is in the file.
Is there an option I should give to ssh or something. Like I said, on
FreeBSD 9.x I do not see this.

Thanks for your time.
regards
Johan




More information about the freebsd-stable mailing list