Im sure this is an easy question, but since im a perl n00b, here it goes
I need to run an executable to my Ubuntu Linux box, get the status of something then use that status to fill out and if/else statement
This is what I have right now
my $enable_poe = `poe ds`; if ($enable_poe eq 'POE device missing or unpowered') { print $enable_poe, "\n", "Your Poe IS NOT enabled, dummy\n"; } elsif($enable_poe eq 'Device ID 2, Rev. 0') { print $enable_poe, "\n", "Your PoE IS enabled, dummy\n"; } else { print "\nnothing happened\n"; }
when I run poe ds on the terminal it will either return
user@device:/tmp$ poe ds Device ID 2, Rev. 0
if the port is active or
POE device missing or unpowered
if the device is missing
Whats happening is the print statement to return the value of $enable_poe is working, but the if/else conditions are not
In this case, if the poe ds command recognizes the unit and returns
Device ID 2, Rev. 0
But the output of the script reads
Device ID 2, Rev. 0 Your Poe IS NOT enabled, dummy
so its returning the first print statement and not reading the
if ($enable_poe == 'POE device missing or unpowered')
line
What am I doing incorrect here? I want the poe ds command to be read, then use what it returns in that if/else statement
Code tags added by GrandFather
In reply to Returning a string from executable by Luken8r
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |