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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
iam not able to run below rsh command having the for loop having back tips in it
please suggest i wasted whole one day to figure it out
but still no solution.
please assits what is the issue
rsh -l <user name> <machine name> "for i in `cat ~/file`
i am using redhat linux 5
What do you want to do using this script.
I think this for loop will show every word before space as a separate line.
Have you run this for loop on your system first? Is it giving proper results?
If you want to run on other machine, you can use ssh too.
I can give you example to run the script using ssh.
You have used double quote that can be the problem.
An example to run the script containing loop
ssh 192.165.xx.xx 'for i in `cat /path/of /the/file` ; do echo $i; done'
My public key is saved as 'authorized_keys' in .ssh of server that's it does not ask me password while running the script.
Where are you getting the problem?
Is it just finished showing command prompt of remote machine and not executing the rest of the script?
Paste your error, if there is any.
Do the pwd without the ps... the string you get back will be something like '/home/username'.
The ps -ef command will give you strings like "gdm 6765 1 0 Feb27 ? 00:00:00 /usr/libexec/at-spi-bus-launcher" or "username 30558 1 0 08:59 ? 00:00:02 nautilus -n"
Command executed do not necessarily have "/home/username" format... usually they are relative paths, not full paths (as shown in the second line - the command is nautilus... but unless the user types in the full path /usr/bin/nautilus to start the program, the "/usr/bin" will not be present, and neither will the "/home/username/xxx" show for the "xxx" program - only "xxx" will be there.
BTW, the reason your `pwd` only executes locally because your string is being interpreted locally before being passed to the remote system. If you want to pass the `pwd` to the remote system, enclose the command string with single quotes (apostrophe) instead of double quotes.
thanks everyone for your help, jpollard your suggestion worked when i used the single quotes with back ticks in my rsh command
i have one last issue now, let me explain my scenario to clear out the confusion , i am invoking below command
rsh -l <username> <machinename> 'cd $DIR_LOCATION; ps -aef | grep `pwd` | grep -v grep| grep -i catalina;echo $?'
now what is happening is that $DIR_LOCATION variable is not getting replaced with its value as i am using single quotes but the irony the back tick only works in single
quotes. I tried using doube quotes in place of single but then the command in back tick is not getting executed.
we have one legacy application which is been configured with rsh oonly not ssh,thats why i have to go with that only
Please please share your thoughts & help me in resolving this issue
thanks again for your time.
This is because you've declared this variable in on your local machine, but trying to use it on remote machine. DIR_LOCATION is not any shell or environmental variable, so your system cannot take it's value until it's declared in the remote system.
~$ rsh -l <username> <machinename> "./myscript.sh"
~$ rsh -l <username> <machinename> "bash myscript.sh"
~$ rsh -l <username> <machinename> "./myscript.sh <something>"
Note: <something> will be used as $1 i.e. argument passed to the script.
Also take a note, do not use $ symbol before variable name while declaring it. But use when invoking it.
Last edited by shivaa; 03-02-2013 at 10:56 AM.