Linux - NewbieThis 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
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.
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.
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.
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.
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.
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.
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).
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.