Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ssh'ing strings

Status
Not open for further replies.

alanpclarke

Programmer
Joined
Aug 30, 2007
Messages
1
Location
AU
Hi,

I am having a really annoying problem with a small perl script I am writing. Basically the issue is that I create a string by joining variables together and I can see that it joins successfully as I print out the result

$Var1 = "Disk Size exceeds ";
$Var2 = "95%";

$Alarm = $Var1 . $Var2;

print $Alarm;

--Output--
Disk Size exceeds 95%

Thats works fine but the problem is that I run the following command
`ssh alarmserver "genalm -a 2020 alarm-log -p $Alarm"`;

*Genalm is just alarm logger where you pass error codes and text to

The problem is that when the alarm message appears on the alarmserver the output is the following

Error Code: 2020 Error Text: Size

It seems to chop up the $Alarm variables according to spaces but I no idea why it would pick the second word in the string as if it was reading in the last variable it would be 95%!!

Can anyone help me? I have tired using the join command insttead of the dot joining. I have also tired to use escape chaceters but no joy. I am sure it is a simple problem but I have gotten a bit tunnel visioned..any help would be great!
 
I don't think that this is a Perl problem.
You had better asked in a Unix forum, imho.

But for further diagnosis:
Log in to alarmserver, and type this at command prompt:
genalm -a 2020 alarm-log -p Disk Size exceeds 95%

Does the output meet your expectations?
Or is it the same as from ssh?
 
I think your missing a set of quotes
`ssh alarmserver "genalm -a 2020 alarm-log -p "$Alarm""`;
might have to escapge them with 3 \'s but I can't remember
`ssh alarmserver "genalm -a 2020 alarm-log -p \\\"$Alarm\\\""`;




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top