Trouble with "|" when creating a variable using perl
greetings,
not being much of a perl user i'm having an issue when trying to assign a value to a variable using the following:
when i execute the perl script i'm using the -w option to get some useful info on how the script is doing (or not doing) and i get the following output:
it clearly doesn't like my syntax and and appears that it's executing the "| tail -n 1" on its own command line. i've tried dbl quotes and escapes and haven't found the magic combo. i am executing this perl script from a bash shell fyi. any suggestions?
First, it's not perl that's not liking your syntax -- it's sh.
Which means that, yes, perl is running a new shell each and every time you use backticks.
So by embedding lots of shell code in backticks, you are running dozens of shells instead of one single one.
As for what's upsetting sh here... I'm guessing perl is shoving the string into sh inside single-quotes, which you are ending early with your own single quotes. Try unescaped double quotes.
i understand that it's the shell that dislikes what it's getting from the perl script. i just don't know how to get perl to give the shell what i'm obviously trying to pass to it. the escaped dbl quotes yielded the same result. if this helps, the line below works but i'm trying to eliminate the su and rsh and simply gettin what i need from the now nfs mounted filesystem where $Glstat lives:
$Glstat is a large output file from a running process. unfortunately the line i'm looking for is in it many times, hence the need to tail -n 1 to grab the last occurrence of it. fyi, i managed to define the $Glstat variable as follows and got away with it:
thanks.
---------- Post updated 03-21-13 at 10:09 AM ---------- Previous update was 03-20-13 at 11:56 AM ----------
---------- Post updated at 10:10 AM ---------- Previous update was at 10:09 AM ----------
mystery solved!
i found out we had a perl developer here so i posed the question to him. he said that his first thought was that "$Glstat" had a newline. so he told me me drop the code below right after setting it:
Hi 2 all,
i have had AIX 7.2
:/# /usr/IBMAHS/bin/apachectl -v
Server version: Apache/2.4.12 (Unix)
Server built: May 25 2015 04:58:27
:/#:/# /usr/IBMAHS/bin/apachectl -M
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
mpm_worker_module (static)
... (3 Replies)
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Hi all,
Can anyone guess why this is happening? I am new to Perl, so please help me to fix this error:
- I have a static html file which calls the cgi-perl script.
HTML Code:
<html>
<head>
<title> Hey Dude! </title>
</head>
<body>
<form method="POST"... (3 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
How do I create shortcuts? For example:
I just want to type one key "l" and have it output the command of "ls -lah"
I believe it's creating a file called l with 755 permissions but I'm not sure where to put the file.
*if it matters, I'm on a shared hosting web server using cPanel with... (2 Replies)
I have a question regarding to the following code:
foreach my $Cnt ( @Cnts ) {
my $abc = xyx->new();
do sth...
aggregatedData->processData($abc);
}
my question is: whether perl will release the memory assign to "my $abc" each time after
processData($abc) is being executed. ... (2 Replies)
been a while so i'm a bit rusty and need a little help. writing a script that needs to compare $EXECHOST(a number) against a numerical range and then set a value. below isn't working but should give you folks an idea of my goal:
if ; then
echo "This is a 32B machine, exiting..."
if ;... (4 Replies)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)