Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-04-2008, 11:22 PM
|
#1
|
Member
Registered: Aug 2003
Posts: 426
Rep:
|
bash - start remote script from local script?
i have a bash script that runs on my local computer
and moves files from one remote computer to another
for processing. the processing computer executes its
processing via its own bash script.
is there a way i can have my local computer's script
tell the processing computer to run its own processing
script? currently, i'm waiting for the local script to
complete and then going over to the processing computer
to start its script. would be a lot easier if i could
put it all into the local script. just have no idea
how.
thanks,
BabaG
|
|
|
04-05-2008, 12:05 AM
|
#2
|
Member
Registered: Jun 2007
Distribution: Slackware, Gentoo, Debian
Posts: 36
Rep:
|
using SSH
Hi babag,
My suggestion is to use ssh to send commands to your remote computer.
on your script you can add:
ssh <remote computer's IP address> <command>
I hope that I help a little bit.
B.T.W
You can even remove the request to enter password by adding your RSA key
to the remote computers authorized keys list.
Regards,
|
|
|
04-05-2008, 12:50 PM
|
#3
|
Member
Registered: Aug 2003
Posts: 426
Original Poster
Rep:
|
great suggestion neuzen. one question: if, as you suggest,
i issue a command via ssh, and that command is to run a
script on the remote computer, when does my local script
continue? after the ssh command is issued? after the remote
script starts? after the remote script ends? if it's the
last of these possibilities i'd have a problem since the
remote script will take hours to run and i'm ready to move
on as soon as it's been told to start running.
thanks,
BabaG
|
|
|
04-05-2008, 10:54 PM
|
#4
|
Member
Registered: Aug 2003
Posts: 426
Original Poster
Rep:
|
oops. just hit a snag. got ssh working and can start a remote
script from my local script (yay!). problem is, remote script
has to be in remote's home directory, not subdirectory. i
need to send both a cd command, as well as the command to
start the script. so far, all i know how to do is the login
and send one command. i have this to run the script if it's
in the home directory:
ssh useracct@remotecomputer ./script_to_run.sh
what i need to be able to do is something like:
ssh useracct@remotecomputer cd Documents/Scripts ./script_to_run.sh
how do i send more than just the one command?
thanks,
BabaG
|
|
|
04-06-2008, 12:54 AM
|
#5
|
Member
Registered: Jun 2007
Distribution: Slackware, Gentoo, Debian
Posts: 36
Rep:
|
no problem.
Hi BabaG,
This is no problem,
You just include the script path, for example lets say you want to run command from /sbin/MyCommand you should type:
ssh <remote computer IP> /sbin/MyCommand.
Or you can just include your command path to PATH (env. variable) on your remote computer.
Regards,
|
|
|
04-06-2008, 01:00 AM
|
#6
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
Including the full path to a command (or fully defining the environment) is best practice for scripts anyway. A change in the environment won't run the wrong command.
|
|
|
04-06-2008, 01:35 AM
|
#7
|
Member
Registered: Aug 2003
Posts: 426
Original Poster
Rep:
|
thanks neuzen and jschiwal. i had one of those 'DOH!' moments
driving home after posting the question when i realized just
what you're saying. i'd still be very interested, though, to
know about issuing multiple commands through an ssh script.
thanks again,
BabaG
Last edited by babag; 04-06-2008 at 01:37 AM.
|
|
|
04-06-2008, 06:46 PM
|
#8
|
Member
Registered: Aug 2003
Posts: 426
Original Poster
Rep:
|
just noticed this:
ssh <remote computer IP> /sbin/MyCommand
has no "." before the command. running the command
without the path included i had:
ssh useracct@remotecomputer ./script_to_run.sh
is there no "."? or should it be:
ssh <remote computer IP> ./sbin/MyCommand
{EDIT}
ok. no "."
it works now.
thanks,
BabaG
Last edited by babag; 04-06-2008 at 07:19 PM.
|
|
|
All times are GMT -5. The time now is 06:52 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|