|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I would like to check programmatically if I can telnet to a Unix box
without errors. I know an extensive solution would require Expect for analyzing output but I am looking for something simple. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
2006-08-18, 14:23(-07), SQ:
> I would like to check programmatically if I can telnet to a Unix box > without errors. > > I know an extensive solution would require Expect for analyzing output > but > I am looking for something simple. If you want to verify that you can login with your user and passwd, then you'll need something like expect. if HOST=machine USER=me PASS=pass expect -c ' spawn telnet $env(HOST) expect_after timeout {exit 1} eof {exit 1} expect { "ogin:" { send "$env(USER)\r" expect assword: {send "$env(PASS)\r"} } assword: {send "$env(PASS)\r"} } expect -re {[$#>] }' > /dev/null 2>&1 then echo I could login to that machine fi Alternatively, you can do: { { sleep 5 echo me sleep 2 echo pass sleep 10 } | telnet machine 2>&1 echo } | grep -q '[$#>] ' But that would be less reliable -- Stéphane |
|
![]() |
| Outils de la discussion | |
|
|