run commands in remote machine
hi,
Iam using redat EL4. I want to do run some commands on a remote machine using ssh through a script. I already setup ssh-keygen and all so that ican run some commands using cronjob. Now i want to create database ( postgreqsl) in remote machine at a predfined time. The commands to executed on remote machine are #service postgresql restart #su postgres $dropdb testatabase $psql testdatabase $\i testdatabase.sql $\q $ctrl+d how can i do that. please advice. thanks Lhrt |
Just put in all the commands into a file (shell script).
eg: #vi /root/myscript.sh #!/bin/sh service postgresql restart ## Put any other commands here su - postgres ## Put your postgresql commands here exit chmod the script to make it executable #chmod -v 700 /root/myscript.sh and use ssh as you normally would, except that you append the scriptname after the ssh command. #ssh machinename /root/myscript.sh That should do the trick. Hope that helps. |
thanks man...
|
All times are GMT -5. The time now is 12:56 PM. |