Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Strings in perl

Options
  • 31-08-2007 7:41am
    #1
    Closed Accounts Posts: 181 ✭✭


    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!


Comments

  • Registered Users Posts: 6,509 ✭✭✭daymobrew


    Maybe it doesn't like the spaces in the $Alarm string. Maybe add escape double quotes to the backticks call.
    `ssh alarmserver "genalm -a 2020 alarm-log -p \"$Alarm\""`;
    


Advertisement