![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Commands to copy a tar.gz file from a Remote Unix Server to Local Desktop. | marconi | UNIX for Advanced & Expert Users | 3 | 08-28-2008 02:06 AM |
| Problem in running bash shell commands on HP-UX machine | abhishek0071 | UNIX for Advanced & Expert Users | 6 | 02-15-2008 03:30 PM |
| lom don't execute commands | pasalagua | SUN Solaris | 6 | 01-25-2008 04:22 PM |
| How to execute multiple commands via ssh | srage | Shell Programming and Scripting | 9 | 01-05-2008 03:18 AM |
| how to execute shell commands in awk script? | RishiPahuja | Shell Programming and Scripting | 1 | 09-02-2005 09:37 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Can BASH execute commands on a remote server when the commands are embedded in shell
I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config.
I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little bewildered about whether I can execute commands on the remote server from within my BASH script. I am thinking that It would be necessary to use expect. I have looked at expect and am not sure I want to go there. I currently have # ./copy_to_server httpd.conf.new /etc/httpd/conf/ 192.168.1.100 #/bin/bash FILE1=$1 FILE2=$2 FILE3=$3 FILE4=$4 FILE5=$5 FILE6=$6 if [ ! -f "$FILE3" ]; then scp $FILE1 $FILE3:$FILE2 else echo "$FILE3 is not up" fi ########## So the file is on the remote server, now I want to move around some exsting files. Now I am unsure how to set up to check for the existing httpd.conf and move it around on the remote server using BASH. [ -f /etc/httpd/conf/httpd.conf ] mv /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bk_up mv /etc/httpd/conf/httpd.conf.new /etc/httpd/conf/httpd.conf And then log off Can BASH do this on its own? I thought that one way around this would be to create a cron job to check /etc/httpd/conf/ dir for a new file when it finds httpd.conf.new it could move over the old and move in the new. So now I am curious is executing multiple commands on a remote server via bash possible? and then logging off. Any suggestions are appreciated. Last edited by bash_in_my_head; 12-04-2008 at 09:50 PM.. |
![]() |
| Bookmarks |
| Tags |
| shell script, shell scripting, unix scripting, unix scripting basics |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|