LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 02-25-2008, 03:52 AM   #1
bad_jaye
LQ Newbie
 
Registered: Feb 2008
Posts: 4

Rep: Reputation: 0
HELP!! running program to ssh


Hi--

Im running a simple script to login to a remote server thru SSH and run a command.

#! /bin/sh +x
ssh user@server -2Y -C "(cd /RMA/prod/files/g3/area11/logs; ls -ltr)"

The script works fine but the script returns to the original host after executing the command, I want the script to execute the command without exiting on the remote server so i can run another command.

This may sound easy but it got's me a headache and I'm feeling the answer is right under my nose!

Can somebody help me, I really appreciate it!

Thanks!

bad_jaye
 
Old 02-25-2008, 06:43 AM   #2
mahmoud
Member
 
Registered: Apr 2006
Location: UK
Distribution: Mandriva, Debain, Redhat, Fedora, Ubuntu, FreeBSD
Posts: 269

Rep: Reputation: 30
Have you tried using pipe
command1 | command2
 
Old 02-25-2008, 01:10 PM   #3
ehawk
Senior Member
 
Registered: Jul 2003
Posts: 1,257

Rep: Reputation: 48
Here is another interesting possibility. Have your script do three things:

1) Make the ssh connection
2) Copy a file (another script) to the remote server
3) Execute the copied script

That way, you could make the script do whatever sequence of instructions you wanted. If you don't know what you want to do until you see some output, and still stay logged in, that is a little tougher.

It logs you out at script completion because staying logged in remotely with execution privileges is a security risk.
 
Old 02-25-2008, 06:24 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
There are basically 3 options:

1. if you really don't know what the next cmd will be, then you have to do it (login) manually
2. if you can make an intelligent script that can determine which cmds to run (eg Perl), then either
2a. copy script over and run it (as suggested) each time OR
2b. copy script over once only and auto run it each time you login (like your current version).
 
Old 02-25-2008, 07:23 PM   #5
bad_jaye
LQ Newbie
 
Registered: Feb 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Appreciate the help, but this doesn't solve the problem.
I needed the script to not exit the remote server after executing the commands. I needed to run a program at the background and I needed the command prompt available.

Any other bright ideas?
 
  


Reply

Tags
commands, help, ssh



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
how to keep program running after closing ssh session fakie_flip Linux - Software 10 11-03-2011 08:33 AM
Running program from terminal with & does nothing, program stops DittoAlex Linux - General 1 10-05-2007 01:35 AM
Running Program Through SSH windisch Linux - General 6 10-04-2005 06:10 AM
Keeping a program running between SSH sessions ark86 Linux - Newbie 2 10-01-2005 03:31 PM
Running a program in the background - SSH ziggo0 Linux - Newbie 4 03-05-2005 01:30 PM

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

All times are GMT -5. The time now is 01:07 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