LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Scripting (https://www.linuxquestions.org/questions/linux-newbie-8/scripting-726251/)

Pantene 05-15-2009 12:35 PM

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.

Poetics 05-15-2009 12:37 PM

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.

Pantene 05-15-2009 12:48 PM

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

forrestt 05-15-2009 12:54 PM

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

Pantene 05-15-2009 12:58 PM

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

forrestt 05-15-2009 01:05 PM

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

rg.viza 05-15-2009 03:28 PM

Quote:

Originally Posted by Pantene (Post 3542058)
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


All times are GMT -5. The time now is 10:20 AM.