LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-27-2005, 10:37 PM   #1
thorney
Member
 
Registered: Jul 2005
Location: Canada
Distribution: Ubuntu Hardy
Posts: 98

Rep: Reputation: 15
Need help with shell scripts


Hi,

How do I write a shell script that logs me into a remote machine, executes commands on the remote machine and then exits and returns me to my local machine prompt? (I have setup ssh to allow key authentication.) Any help would be awesome!!

thanks
 
Old 11-27-2005, 10:59 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Something like this?

Code:
#!/bin/bash
scp file user@remote-machine:/path/to/file
ssh user@remote-machine "commands; ..."

Cheers,
Tink
 
Old 11-27-2005, 11:09 PM   #3
thorney
Member
 
Registered: Jul 2005
Location: Canada
Distribution: Ubuntu Hardy
Posts: 98

Original Poster
Rep: Reputation: 15
Ya I guess. So I take it that any commands that are in quotes get executed on the remote machine!?
 
Old 11-27-2005, 11:17 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
That's right. If it's only a single command you can skip the
quotes, too.


Cheers,
Tink
 
Old 11-27-2005, 11:18 PM   #5
thorney
Member
 
Registered: Jul 2005
Location: Canada
Distribution: Ubuntu Hardy
Posts: 98

Original Poster
Rep: Reputation: 15
Thanks Tinkster
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell scripts rocketgo Linux - General 10 12-01-2003 05:20 AM
Shell Scripts benwy Linux - Software 1 06-09-2003 02:58 AM
Shell scripts anon227 Linux - Software 1 01-03-2003 03:11 PM
shell scripts nautilus_1987 Linux - General 3 08-30-2002 03:12 AM
shell scripts gui10 Programming 10 10-28-2001 02:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration