Find the answer to your Linux question:
Results 1 to 2 of 2
Can someone please tell me, why I'm getting an error mesg while trying to run the rsh command using a variable "a" and not getting an error mesg, when firing ...
  1. #1
    Linux Newbie Sangal-Arun's Avatar
    Join Date
    May 2006
    Location
    Gurgaon, India + Denver Colorado USA
    Posts
    101

    Unhappy rsh multicommand issue

    Can someone please tell me, why I'm getting an error mesg while trying to run the rsh command using a variable "a" and not getting an error mesg, when firing the same command (stored inside variable "a" on $ prompt)..................??? Do i need to export any variables or do a "cd" inside..!!!!

    Code:
    [/Fare/loggers/build] $ echo $c1; echo $c2; echo `hostname`
    hostname -s
    hostname -i
    e1d1nas10.somecompany.com
    
    [Fare/loggers/build] $ a="rsh -l build 53.3.101.185 \"$c1 ;$c2\""
    
    [/Fare/loggers/build] $ echo $a
    rsh -l build 53.3.101.185 "hostname -s ;hostname -i"
    
    [/Fare/loggers/build] $ $a
    bash: hostname -s ;hostname -i: command not found
    
    [/Fare/loggers/build] $ `$a`
    bash: hostname -s ;hostname -i: command not found
    
    [/Fare/loggers/build] $ rsh -l build 53.3.101.185 "$c1 ;$c2"
    e1d1nas10
    53.3.101.185
    Brgds,

    ARUN SANGAL
    SCM: 1- 720 251 9962
    Email: sangal.ak04@gmail.com
    Email: sangal_ak04@yahoo.com

  2. #2
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    It's because the double quotes aren't being seen by your shell so the quoted string is appearing to rsh as a single command with embedded spaces. Try executing the variable with eval and see the difference! - $ eval $a

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...