The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-03-2008
bash_in_my_head bash_in_my_head is offline
Registered User
  
 

Join Date: Dec 2008
Location: Southern California
Posts: 7
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..
  #2 (permalink)  
Old 12-04-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
You should start reading about ssh.
Closed Thread

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:34 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0