Passing $variable to rsh

Posted on 2003-03-10
Medium Priority
Last Modified: 2013-12-26
I need a way to pass a variable from a shell script to rsh.  Currently rsh ignores the $variable.  This is running on AIX version 4.3.  Here is the command I am trying to execute:

rsh server01 'cp -p $dir/$filenm $dir/$filenm.old'

The userid has permission to run rsh and write to the directory on the remote server specified by the $dir variable.
Question by:gwj
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 21

Accepted Solution

tfewster earned 1000 total points
ID: 8104819
Use double quotes, i.e.
rsh server01 "cp -p $dir/$filenm $dir/$filenm.old"
LVL 21

Expert Comment

ID: 8104914
Use double quotes, i.e.
rsh server01 "cp -p $dir/$filenm $dir/$filenm.old"

The variables within the double quotes are substituted before they are executed by rsh

(Strange, I thought I had posted this once...)


Author Comment

ID: 8104931
The search feature was disabled when I entered the question.  I had tried double quotes but only around the $variables, not the whole command.  Thanks.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question