I have the following script in tcsh that looks like this:
df=`ssh $some_server 2>/dev/null df $2 -k`
echo $df
Perl script runs this tcsh script and I have the two following questions:
- What does the first command do?
- How can I determine if I have the ssh keys, before running this command (from the
perlscript for example, or thetcshscript?
As I understand, If I don't have the ssh keys, it will ask for the password. I would like to print a basic warning to the user if he doesn't have the ssh keys.
system()call where you can pass a list of parameters, so that you do not use the shell. Modules likeIPC::Runmay also help you write this more cleanly, specially when needing to deal with STDOUT/STDERR. Also, you have various Perl libraries that gives you SSH protocol features, either as rewritten or as a layer on top of it.Have a look at them, even if the question "do we have the proper keys" is complicated(depends on config)-o BatchMode=yesto check if passwordless login is possible. For example:ssh -o BatchMode=yes userName@server true >/dev/null 2>&1 || echo "Passwordless login is not possible". See this answer for more information