the error message in cygwin is:-
perl: No match.
| sort -u`;chomp @a ; print @a;: Command not found.
error message on Solaris is:-
Can't find string terminator "`" anywhere before EOF at -e line 2.
bash : | sort -u
`; chomp @a ;
print @a ;
: command not found
even I try qx// instead of `` without any use.:(:(
Whenever you need to embed single-quotes in a single-quoted string, you need to first close the single-quoted string, add a backslash-escaped single-quote, then reopen the single quoted string immediately afterwards (all of this is to appease the shell's parser, it has nothing to do with perl).
So
'
becomes
'\''
for every instance of a single quote you'd like to place inside a single-quoted string.
I tried it with the same error this was one of my tries. but with out any use. actually the system is ignoring the 'print \$F[0]' and print all the who command o/p.
Just to be sure you realize it, allow me to reiterate: The code being passed to the perl interpreter is mangled by the single-quote problem I explained in my prior post. If you are pursuing a different solution that does not use any perl code with single quotes within a single quoted string that's parsed by the shell, then cool. Nevermind this paragraph
By the way, your original code with properly-escaped single quoting (as in my first post) works fine.
thank you guys for your reply I think some think wrong in my server I don't know where the problem is exist but I hope you could suggest to me where to start troubleshooting this.
radoulov thank you for your previous solution it worked great.
Alister:- I have also tried awk '{print $1}' instead of the inner perl in my code but with same problem!!!!
but guys is my problem related to any env variable in my system?
---------- Post updated at 21:43 ---------- Previous update was at 21:36 ----------
Or, of course, as alister correctly pointed out, you need to close the external/escape the embedded single quotes. alister's solution works fine for me too:
Perl isn't my area, but i would suggest that you take the perl code you're passing on the command line and place it in a file, then tell perl to interpret that file. If you still get an error, then it's likely that the problem is perl related. If that works fine, then you can be reasonably sure that the issue lies with your shell. Worst case scenario, install windows and code it in powershell