expect + last few arguments as one
- From: Nichu <nichu@xxxxxxxxxxxxx>
- Date: Fri, 23 May 2008 13:52:44 +0200
Hello
I'm trying to execute some commands on remote machines using expect ...
my script looks like that:
#!/usr/bin/expect -f
set password [lrange $argv 0 0]
set ipaddr [lrange $argv 1 1]
set scriptname [lrange $argv 2 20]
set timeout -1
spawn ssh $ipaddr $scriptname
expect "*?assword:*"
send -- "$password\r"
expect eof
I execute this script like:
../ssh_login.sh PASSWD IP COMMAND
and generally it works great
BUT
i would like to execute script on remote machine and result of it direct to different text file (on remote machine as well) AND here i have problem
because I can't use:
../ssh_login.sh PASSWD IP script > /tmp/result.txt
because of course it will direct result to local file
and when I try
../ssh_login.sh PASSWD IP "script > /tmp/result.txt"
it doesn't work:
../ssh_login.sh PASSWD IP "who > /tmp/result.txt"
spawn ssh debian {who > /tmp/xinetd.txt}
nichu@debian's password:
bash: {who: command not found
I tried with different characters and still doesn't work...
any ideas?
Thanks for any help
regards
nichu
.
- Follow-Ups:
- Re: expect + last few arguments as one
- From: Bill Marcum
- Re: expect + last few arguments as one
- Prev by Date: Re: Shell script won't run properly from bash_profile.
- Next by Date: Re: expect + last few arguments as one
- Previous by thread: golden suppliers,lowest prices .cover all brand products accept PAYPAL .
- Next by thread: Re: expect + last few arguments as one
- Index(es):
Relevant Pages
|
Loading