rbhagwandin
June 4th, 2008, 04:08 PM
First of all, hello!
I'm trying to create a line of code, using expect within a shell script, that will assign a variable the value of "grep -c "Hi" /home/myAccount/file
count=$(expect -c "spawn ssh root@127.0.0.1 \"grep -c \"Hi\" /home/myAccount/file\"
expect \"*?assword*\"
send \"supersecurepassword\r\"
")
I'm using a different IP address (obviously) and a different file, but the structure is more or less the name.
This is what I've got so far. When run without the expect stuff as:
count=`ssh root@127.0.0.1 "grep -c Hi /home/myAccount/file"`
it works perfectly, setting count to the number of lines containing Hi, as it should.
Any ideas? With the expect code, $count ends up being the console output (the command run and the prompt for the password)
I'm trying to create a line of code, using expect within a shell script, that will assign a variable the value of "grep -c "Hi" /home/myAccount/file
count=$(expect -c "spawn ssh root@127.0.0.1 \"grep -c \"Hi\" /home/myAccount/file\"
expect \"*?assword*\"
send \"supersecurepassword\r\"
")
I'm using a different IP address (obviously) and a different file, but the structure is more or less the name.
This is what I've got so far. When run without the expect stuff as:
count=`ssh root@127.0.0.1 "grep -c Hi /home/myAccount/file"`
it works perfectly, setting count to the number of lines containing Hi, as it should.
Any ideas? With the expect code, $count ends up being the console output (the command run and the prompt for the password)