in reply to Re^2: Cutting last word from a output line
in thread Cutting last word from a output line

I continue taking your specs literally.

I assume that you:

So i jumped to the conclusion, that you need something like this:

karls-mac-mini:monks karl$ sysname=$(./snmpwalk.pl | perl -ae 'print p +op @F') karls-mac-mini:monks karl$ echo $sysname USWLS-P-TR03-C4510RE-1.adagnet.net

See also I know what I mean. Why don't you?.

BTW, if you are on Windows, where does your awk come from? Cygwin? Or do you expect a port to PowerShell?

Edit: Strucked out useless/annoying comment.

Regards, Karl

«The Crux of the Biscuit is the Apostrophe»

Replies are listed 'Best First'.
Re^4: Cutting last word from a output line
by Bharath.M.R (Initiate) on Feb 28, 2015 at 16:07 UTC
    Thanks Karl, I just gave an example how i was achieving in unix shell. Ok i will try to re-phrase the question. I am expecting like below. Assume below is an system command: "snmpwalk.ovpl -c $string $IP sysName" here windows system command "snmpwalk.ovpl -c $string $IP sysName" will give me output like below. sysName.0 : OCTET STRING- (ascii): USWLS-P-TR03-C4510RE-1.adagnet.net So as said earlier i am expecting something like below.: my $variable = `system (sysName.0 : OCTET STRING- (ascii): USWLS-P-TR03-C4510RE-1.adagnet.net) | cut last word` expected $variable=USWLS-P-TR03-C4510RE-1.adagnet.net

      Thank you very much. So the solution given above by kroach works for you.

      Regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

Re^4: Cutting last word from a output line
by Bharath.M.R (Initiate) on Feb 28, 2015 at 18:16 UTC
    Thank you all, this is all i wanted to know :)
    ############################################### my $output = `nnmsnmpwalk.ovpl -u system -p manager123 -t 10 -c $Strin +g $IP sysName`; my $sysName = (split /\s/, $output)[-1]; print "system name is $sysName\n";
    THanks, Bharath

      Are you sure?

      Regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

        Yes Karl, Thank you so much for your efforts. And sorry for dirty post framing. Could'n get how to parenthesize the post using HTML.