LinuxQuestions.org
Visit Jeremy's Blog.
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 05-15-2009, 01:35 PM   #1
Pantene
LQ Newbie
 
Registered: May 2009
Posts: 3

Rep: Reputation: 0
Thumbs up Scripting


New member needing some help with a script. With in my script I am needing a command that will automatcilly stop a process on a differnet platform, stop or put it to sleep just right beform my program begins to run. I believe it might be a simple command, involving the ssh command with aplicable permission (authentication) between the two different plaforms to access/scriptively to login into this terminal to stop this process from running. I am not a script writting person, but can read and diagnose a script, but write one -this is where my weakness appears. Please helf, a suggestion is needed quickly. Thank you, Pantene.

Last edited by Pantene; 05-15-2009 at 01:39 PM.
 
Old 05-15-2009, 01:37 PM   #2
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
So I understand your question:

You have a script (bash? perl? php? something else?) that, when run, needs to disable a process on a remote system. Is this correct?

If you want to do this via ssh you'll want to look at passwordless logins (there are many, many threads on this here at LQ), as well as `man kill` to read about stopping other processes.
 
Old 05-15-2009, 01:48 PM   #3
Pantene
LQ Newbie
 
Registered: May 2009
Posts: 3

Original Poster
Rep: Reputation: 0
This will be a bash script, and during the time of script execution, this line will send a signal to the remote system to either stop, or put the remote system process to sleep. I would also thing the ssh process will be involve. Now the passwordless login will be ideal. Can you help me with devising such a command within my script to execute this operation. Please advise.

Thanks,

Pantene

Last edited by Pantene; 05-15-2009 at 01:53 PM.
 
Old 05-15-2009, 01:54 PM   #4
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
You're not really being clear. Perhaps if you gave us the email address of your professor, we could ask him our questions directly.

Forrest
 
Old 05-15-2009, 01:58 PM   #5
Pantene
LQ Newbie
 
Registered: May 2009
Posts: 3

Original Poster
Rep: Reputation: 0
OK, once more. Within my script need a command that will send a signal to a remote linux terminal to stop a process from running during the period in which my script is running on my platform. I am sorry, but can not make it any clearer.

Again, thanks,

Pantene
 
Old 05-15-2009, 02:05 PM   #6
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
OK, if you can give me the answers to the following questions, I will help you put the pieces together:

Note:
I don't need the parameters to the commands, just the commands.
I don't want specifics related to you, just generally.

1) How do you log into a remote machine with ssh?
2) What commands do you need to run to set up passwordless ssh connections between hosts?
3) What command do you use to stop a process?
4) What command do you use to determine the process id that you want to stop?
5) Give me as least an attempt to put the above 4 together in a script.


I'll even go a little further. If you can come up with ANY answer to the above that is close, I'll consider it correct.

I'll help you with your homework, but I'm not doing it all for you (You'll appreciate it in the future).

Forrest
 
Old 05-15-2009, 04:28 PM   #7
rg.viza
Member
 
Registered: Aug 2006
Posts: 74

Rep: Reputation: 15
Quote:
Originally Posted by Pantene View Post
OK, once more. Within my script need a command that will send a signal to a remote linux terminal to stop a process from running during the period in which my script is running on my platform. I am sorry, but can not make it any clearer.

Again, thanks,

Pantene
These are macro instructions. Google for the details.

Set up a user account for this job on the remote box and set up SSH key auth for the user. As far as stopping the process, figure out what the command is to stop the process.

then in your script:
Code:
/path/to/ssh user@host '[command]'
The key auth is necessary because you can't log in with ssh using a script, nor would you want to because it presents a security hazard to have account passwords laying around in scripts.

You can get your full path to ssh using
Code:
$ which ssh
You should also use full paths to the remote command in [command] in your script. That way if the user environment doesn't have the path set to the command's bin directory in it, your script will still work.

You need to install your private key in the user who will be executing the script so that when it runs, the key is available in the executing user's context. If your account will be running it install it in yours.

-Viz

Last edited by rg.viza; 05-15-2009 at 04:34 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
I am new to scripting PKrishna Linux - Newbie 7 03-17-2008 10:39 PM
scripting help akhil.mud Programming 4 12-14-2007 07:28 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 05:29 AM
Need help scripting Tamara Programming 1 06-05-2005 04:18 PM
Scripting help JediMasterTux Linux - Newbie 2 07-13-2004 02:29 AM


All times are GMT -5. The time now is 10:47 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration