Reputation: 129
I am making a script to access a bunch of machines through ssh and run the df -h
command to check if their disk usage is getting near 100% , my problem is that I can't run the command on the machine that when I run the command, i cant send it to a file in the machine that I am using to connect.
I have tried this
df -h > /dir/file
but that just creates a file in the machine I am connected to. How would I go about doing what I am trying to do?
the full code that im using to do this is
expect <<-EOF
spawn ssh -oPort=23 x.x.x.x df -h > /home/file
expect "*password: " {send "password\r"}
expect "*#" {send "exit\r"}
EOF
Any help is appreciated.
Upvotes: 2
Views: 101
Reputation: 359955
Move the redirection to the beginning of the heredoc:
expect <<-EOF > /home/file
spawn ssh -oPort=23 x.x.x.x df -h
expect "*password: " {send "root\r"}
expect "*#" {send "exit\r"}
EOF
(untested)
Upvotes: 1