Check for condition on remote machine before running command?
Is it possible to, via use of a shell script, to check for a condition (if;then) on a remote machine before executing a command or series of commands on the local machine?
I have 3 different Linux systems that connect to a Mac for backups and other various tasks. I would like to, for example, be able to check the remote machine (Mac) for a certain directory with the current date. If that directory doesn't exist, then the local machine (Linux) will create that directory and perform various tasks on the remote machine. I want to run said script from, a daily cronjob possibly, on whichever of the three Linux systems is booted first. But I don't want it to run the various tasks for any particular day, again, when/if the other systems are booted afterwards. There is no way to predict which of the three Linux systems will be booted first on any particular day, or whether or not any of the others will be booted at all. And I do I have a working password-less ssh connection from each of the Linux machines to the remote machine...if that helps. |
Try:
Code:
ssh root@your_ip "if [ -d '/directory_name' ]; then echo 'yep, that directory is there'; fi;" |
Quote:
|
All times are GMT -5. The time now is 07:09 PM. |