Make a command timeout if not completed in a certain amount of time
Hello,
I'm trying to bascailly find out how i can basically have a script that can properly test for ssh connectivity. basically one way i can see is: ssh ipaddress exit echo $? if 0 then ok if not then failure etc etc but of course this is to test passwordless ssh connectivity is running ok, therefor if it isn't and it gets asked for a password this is no good, and i don't want to test with telnet ipaddress 22 because that doesn't really tell you much. So either a way to make the command timeout if it asks for a password without changing the timeout on the config file, like an escape character being sent to the command after so much time, or i thought possibly read stdin and if it says about entering a password then again we know its failed and can exit and know the ssh didn't work passwordlessly. Anyideas?? Cheers |
Hi.
Code:
ISHELLO=`ssh ipaddress "echo hello"` & $! == the PID of the last command, to see if the ssh connection is still running, and the 'hello' should end up in $ISHELLO if the ssh connection is successful. |
thanks but that didn't work, and i sorted out my own script now so it all works, unles you can see a reason my method would fail for some reason i've missed
Code:
#!/bin/bash Regards Mark |
All times are GMT -5. The time now is 03:22 PM. |