I want to list the files on the remote machine using bash script without entering password.
I am using following command to do it
sshpass -p password ssh [email protected] "ls /usr/local/"
I want to get the exit code from the above command to know my command (ls /usr/local) fails or get passed.
How to do it? Kindly help me
lsin scripts either.sshpass. Also usinglsin scripts is perfectly okay for testing or for output. It can well be a placeholder for a more useful command. I'm pretty sure the OP simply asked how to get the return value of ls through to the calling shell when usingsshpass.