in reply to perl script
I cannot find any reference to a module called QA::STK::Execute, but I will make assumptions based on syntax. If you review the Basic debugging checklist, the first thing you should check is does $output contain what you think it does. printing is the easiest basic check. Given that you are running ls-l in your posted code and not ls -l (note the space), I'd bet you've got empty output.my $ex = QA::STK::Execute->new(ip=>'some ip',user=>'root'); $ex->command("ls-l"); my $rc = $ex->execute(); my $output = $ex->output();
Once you've verified that it seems reasonable, you can either use index as Corion suggested, or craft a regular expression. A regular expression has the advantage of anchoring to the end of a line, since you are looking for a file name. Maybe something like:
The easiest way to deal with this is for you to post some example output from ls -l and then what you tried in order to find the file's name, all wrapped in <code> tags.if (/\s\Q$xyz\E$/) { # Code to run }
You will note that your lack of adherence to site expectations has garnered you down votes. Read the links, and see if they make sense. You can even edit your posts to fix them up.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl script
by Anonymous Monk on Jan 12, 2017 at 22:05 UTC | |
by kennethk (Abbot) on Jan 12, 2017 at 23:54 UTC |