Re: expect + last few arguments as one
- From: Bill Marcum <marcumbill@xxxxxxxxxxxxx>
- Date: Fri, 23 May 2008 09:35:32 -0400
On 2008-05-23, Nichu <nichu@xxxxxxxxxxxxx> wrote:
Set up authorized_keys on the remote machine so you don't have to send a
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?
password or use expect.
Use ssh-keygen to generate a key pair on the local machine. Press enter
when it asks for a passphrase. Then use ssh-copy-id to copy the public
key to the remote machine.
.
- References:
- expect + last few arguments as one
- From: Nichu
- expect + last few arguments as one
- Prev by Date: expect + last few arguments as one
- Next by Date: Re: Shell script won't run properly from bash_profile.
- Previous by thread: expect + last few arguments as one
- Index(es):
Relevant Pages
|