Link to home
Start Free TrialLog in
Avatar of shahrahulb
shahrahulb

asked on

command line parameters

i m doing following in my original script:

$string = "Rahul Shah";
$command = "ssh server_name  /u/rshah1/temp.pl QBS $string";
system($command);


my temp.pl script contains:
perint $ARGV[0]  :: $ARGV[1] \n";

the output i get after executing the script is:
QBS :: Rahul

what i want is:
QBS :: Rahul Shah
Avatar of ozo
ozo
Flag of United States of America image

$command = "ssh server_name  /u/rshah1/temp.pl QBS '$string'";
Avatar of shahrahulb
shahrahulb

ASKER

Hi Ozo,

It didn't worked...
the strange thing is, if i manually go to ssh server_name and then run the script  ./temp.pl QBS 'Rahul Shah', that works

but why it doesn't work thru my original script
#or better
system "ssh","server_name","/u/rshah1/temp.pl","QBS","\Q$string\E";
You are amazing, Mr Ozo... That worked...

from where you find all the solutions...can u give me some tips

Rahul
oops. one more issue: i was using:
    my $s_now = time();
    print("$NAME: now = " . scalar(localtime($s_now)) . "\n");
    $string = "$NAME: now = " . scalar(localtime($s_now)) . "\n";
    $string .= "$NAME: using login host= $url\n$NAME: using username= $username\n\n$NAME: Request: GET $url\n";


after executing system "ssh","server_name","/u/rshah1/temp.pl","QBS","\Q$string\E";

the output i get is,
QBS  pos.pl: now = Wed Mar  9 14:00:17 2005

it does not print the line "using login host = .......


Strange
Do you need those "\n" in there?  they are getting interpreted by ssh before /u/rshah1/temp.pl is called
I mean, they are getting interpreted by the remote shell before /u/rshah1/temp.pl is called
"'\Q$string\E'"
yeah. i need "\n"
its very important.

any solution ot my problem
system "ssh","server_name","/u/rshah1/temp.pl","QBS","'\Q$string\E'";
Note the '' in the "" 
i get the output in following manner"
pos\.pl\:\ now\ \=\ Wed\ Mar\ \ 9\ 22\:20\:34\ 2005
pos\.pl\:\ using\ login\ host\=\ https..........

there is an extra "\" embebeded after evry word.

for your infomation, the contents of $string is:
 $string = "$NAME: now = " . scalar(localtime($s_now)) . "\n";
 $string .= "$NAME: using login host= $url\n$NAME: using username= $username\n\n$NAME: Request: GET $url\n";


Rahul
> You are amazing, Mr Ozo... That worked...

concise and bery true.
it is not working for me. i m getting extra "\" character. how do i get rid of that
OZO,

did u try executing:  system "ssh","server_name","/u/rshah1/temp.pl","QBS","'\Q$string\E'";
because i m getting extra "\" character

Rahul
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It Worked. :-)

can u please tell me how did u found the solution

Thanks a lot.