SSH using expect
am 08.10.2007 08:52:00 von nits
I am trying to automate ssh using expect in a script. But when using
expect how can i get arguments. The follwoing is the script i am using
currently
#!/usr/bin/expect -f
spawn ssh -X nitx@192.168.1.69
expect "password:"
sleep 1
send "passwd\r"
interact
what i want is to give IP as an argument to script so that i can ssh
to different machines.
../scrpt.sh
Re: SSH using expect
am 08.10.2007 14:21:45 von colin.macleod
On 8 Oct, 07:52, nits wrote:
> I am trying to automate ssh using expect in a script. But when using
> expect how can i get arguments. The follwoing is the script i am using
> currently
>
> #!/usr/bin/expect -f
> spawn ssh -X n...@192.168.1.69
> expect "password:"
> sleep 1
> send "passwd\r"
> interact
>
> what i want is to give IP as an argument to script so that i can ssh
> to different machines.
> ./scrpt.sh
Try:
#!/usr/bin/expect -f
set ip [lindex $argv 0]
spawn ssh -X n...@$ip
...etc...
For more info see http://aspn.activestate.com/ASPN/docs/ActiveTcl/8.4/expect/e xpect.1.html
Re: SSH using expect
am 11.10.2007 00:01:42 von blacksheep
nits wrote:
> I am trying to automate ssh using expect in a script. But when using
> expect how can i get arguments. The follwoing is the script i am using
> currently
Maybe what you need to do is best performed by generating a
private/public key and exporting it to the target machine.
So your script does not need to provide any password anymore.
--
blacksheep
Re: SSH using expect
am 11.10.2007 18:37:35 von Faust-C
On Oct 10, 5:01 pm, blacksheep wrote:
> nits wrote:
> > I am trying to automate ssh using expect in a script. But when using
> > expect how can i get arguments. The follwoing is the script i am using
> > currently
>
> Maybe what you need to do is best performed by generating a
> private/public key and exporting it to the target machine.
> So your script does not need to provide any password anymore.
>
> --
> blacksheep
yes i agree, using a expect script could be a hazard in the long run
Re: SSH using expect
am 19.10.2007 17:06:14 von nits
On Oct 11, 9:37 pm, Faust-C wrote:
> On Oct 10, 5:01 pm, blacksheep wrote:
>
> > nits wrote:
> > > I am trying to automate ssh using expect in a script. But when using
> > > expect how can i get arguments. The follwoing is the script i am using
> > > currently
>
> > Maybe what you need to do is best performed by generating a
> > private/public key and exporting it to the target machine.
> > So your script does not need to provide any password anymore.
>
> > --
> > blacksheep
>
> yes i agree, using a expect script could be a hazard in the long run
But how to do it? private/public key ??