ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
Hi All,
Need help for writing an automation script. Yet I had written a script but its not working,
Quote:
#!/bin/bash
#copying files from local machine to remote server by scp
scp -r /useradd.sh user@172.29.16.19:/home/user
# Second step making ssh login for executing the script on remote server
ssh@172.29.16.19
# switching user account
su - root (script should run as root)
echo "password"
./home/user/useradd.sh (executing the script)
finally i have to capture a log of the script process.
This is my script for automation, Were i have run the "useradd.sh" script on the remote servers from my local machine.Kindly help me to write a clear script.
Thanks in advance.
1) Please post your code under [code/] [/code] tag.
2) Sorry, I am not clear on what you are looking for, please mention your motive clearly..
But from what i understand, please check "expect" on google.
I hope it helps.
In cases where something doesn't work according to your expectations, it is necessary to tell us what your expectations are. Otherwise, we read the code, observe what it says, and either see that it can't do anything, or see what it does do. If it does something, we can only guess what your intentions were, and there is a vast universe of possibilities for what that might be. Without enough information, I might interpret your intentions incorrectly, and suggest that you need to do something like adding
Code:
// rm command removed
Luckily, this is seldom the solution for anyone, so I'm not suggesting it.
--- rod
Last edited by crabboy; 08-02-2012 at 09:44 AM.
Reason: Removed rm from root command
Not suggesting it, but you felt the need to put it anyway. Modern rm implementations will recommend against it, but I don't think that's a good suggestion as your sarcasm may not be interpreted as such.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.