For ftp you have a quick and dirty trick :
$ ftp -n yourhost <<-here
> quote USER youruser
> quote PASS yourpassword
> ls
> quit
> here
(you can do a put, get, whatever you want instead of “ls”)
For telnet similar idea:
$ (echo -e “open yourhostr”; sleep 2;echo -e “youruserr”; sleep 1; echo -e “yourpassword”; sleep 1; echo -e “unamer”; sleep 1; echo -e “exit”) | telnet
That sound pretty good but … it does not work on solaris (ok on Linux), and no way for ssh ![]()
So if this shoddy doesn’t meet your expectations…
Expect is what you are looking for. Available for GNU-linux, solaris… MSwindows… at http://expect.nist.gov/
For debian do it cool:
apt-get install expect
I do it with 2 scripts. I’m sure that you can do better, but that’s work
– script to call the expect and to make things good looking:
host=$1
psswd=$2
cmd=$3
os=$( ./expectaTion.tcl $host $psswd $cmd| awk “/$cmd/ “‘{getline; print}’|tr -d ‘

– script expect : expectacion.tcl
– end of the script
Pascal.