The solution is to open a shell script with a pipe and send it the
commands to be executed. That way no new shell is opened for each
command and McAfee is quiet:
# open shell with pipe and turn off buffering
open (OPSH, "|-") or exec ("./my.sh 01 >opsh1.log 2>&1");
$savefh
will ignore and the scanning stopped.
>>
>> Then I changed the Perl script to use backticks thinking that it would
>> be faster to just assign the output inside the script. It works, but
>> now McAfee is running hard again and I don't see any speed
>> improvement. E
pening and
reading the file, I observed that McAfee was running hard, apparently
scanning the file for viruses. So I put the scripts into a folder
tree that McAfee will ignore and the scanning stopped.
Then I changed the Perl script to use backticks thinking that it would
be faster to just assign
I observed that McAfee was running hard, apparently
scanning the file for viruses. So I put the scripts into a folder
tree that McAfee will ignore and the scanning stopped.
Then I changed the Perl script to use backticks thinking that it would
be faster to just assign the output inside the script.
R. Hicks wrote:
Are there any gotchas for using qx() to run system commands versus
backticks?
No, it's the same thing.
http://perldoc.perl.org/perlop.html#qx/STRING/
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: beginners-uns
No, qx// is the general form of backticks; however, backticks
themselves are often the wrong choice. Take a look at open,
IPC::Open2, and IPC::Open3.
On Apr 19, 2009, at 15:39, "R. Hicks" wrote:
Are there any gotchas for using qx() to run system commands versus
backticks
Are there any gotchas for using qx() to run system commands versus
backticks?
Robert
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
john wright wrote:
> Hi All,
Hello,
> i am getting error "The system cannot find the path specified" while running
> below lines code.
>
> $dirname = "util";
> $path = ` cd $dirname ; pwd`
> print ("$path");
>
> can anybody help me to get output of pwd in the variable $path.
use Cwd;
my $dir
john wright wrote:
>
> i am getting error "The system cannot find the path specified" while running
> below lines code.
>
> $dirname = "util"; $path = ` cd $dirname ; pwd` print ("$path");
>
> can anybody help me to get output of pwd in the variable $path.
Hi John
It's best to do things in Perl
Hi All,
i am getting error "The system cannot find the path specified" while running
below lines code.
$dirname = "util";
$path = ` cd $dirname ; pwd`
print ("$path");
can anybody help me to get output of pwd in the variable $path.
Thank
John Ackley wrote:
> thanks to all who replied
>
> down to this
>
> # perl -e "print unlink glob
> '/usr/local/billmax/html/images/day-0020a6-5a9bfc*';"
> 1
>
> but in script
>
> my $oldimage = "/usr/local/billmax/html/images/day-0020a6-5a9bfc*";
> my $files = unlink glob $oldimage;
>
> fails
and
perl -e '$oldimage =
"/usr/local/billmax/html/images/day-0020a6-5a9bfc*";$files = unlink glob
$oldimage;printf "Files %d\n",$files;'
Files 1
works
# cat test.pl
#! /usr/bin/perl -w
use strict;
my $oldimage = "/usr/loc
thanks to all who replied
down to this
# perl -e "print unlink glob
'/usr/local/billmax/html/images/day-0020a6-5a9bfc*';"
1
but in script
my $oldimage = "/usr/local/billmax/html/images/day-0020a6-5a9bfc*";
my $files = unlink glob $oldimage;
fails
--
To unsubscribe, e-mail: [EMAIL PROTECTED
On Sat, 2006-08-19 at 16:59 -0400, John Ackley wrote:
> Thanks
>
> in line comments
>
> Tom Phoenix wrote:
> > On 8/19/06, John Ackley <[EMAIL PROTECTED]> wrote:
> >
> >> `/bin/rm -f \"$oldimage\"`;
> >> `/bin/rm /tmp/errormessage`;
> >
> > Why not simply use Perl's unlink function?
>
> apparent
x27;s directory and do the filename pattern
matching yourself with
Perl regular expressions. For this, I suggest checking out the Perl
Cookbook, from O'Reilly
hopefully gone soon!
`/usr/local/bin/gnuplot $gpfile 2>&1 >/tmp/errormessage` ;
Use backticks if you're interested i
d to clean up garbage)
second line could be unlink although that line is just for debug
hopefully gone soon!
`/usr/local/bin/gnuplot $gpfile 2>&1 >/tmp/errormessage` ;
Use backticks if you're interested in the output. But if you're not
looking at the output, you should probabl
On 8/19/06, John Ackley <[EMAIL PROTECTED]> wrote:
`/bin/rm -f \"$oldimage\"`;
`/bin/rm /tmp/errormessage`;
Why not simply use Perl's unlink function?
`/usr/local/bin/gnuplot $gpfile 2>&1 >/tmp/errormessage` ;
Use backticks if you're interested in the
I have a program which should create a new image
after deleting the old. Image names have $$ embeded
to assure uniqueness (within a reasonable period of time).
The following backticks don't work as expected.
`/bin/rm -f \"$oldimage\"`;
`/bin/rm /tmp/errormessage`;
`/usr/lo
rates a text file, this text file
> name is now in the variable: $fmtFile. Later in the program, I want to
> delete this file, but it fails. I don't know why.
>
> In the perl cookbook, it says "The backticks do not return until the
> called program exits"
>
> Is t
: $fmtFile. Later in the program, I want to
> delete this file, but it fails. I don't know why.
>
> In the perl cookbook, it says "The backticks do not return until the
> called program exits"
>
> Is this related?
The book means that backticks don't re
t fails. I don't know why.
In the perl cookbook, it says "The backticks do not return until the
called program exits"
Is this related?
Thanks,
mahdi.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/&g
When I first learned perl I wrote the classic "replace text in files" script
that probably everybody else writes. It is run with:
% replace 'sometext' 'some other text'
... where $match gets the first arg, and $replace gets the second. It
didn't work at first, but someone on this list reco
de. 0
indicates success, non-0 indicates failure. It does NOT return the
output. If output is produced from the program, it's printed to STDOUT.
sub getDate {
print "start date\n";
if ( `/bin/date` ) {
print "can't get date\n";
exit(2);
}
print "fin
Keenan, Greg John (Greg)** CTR ** wrote:
> Hi,
>
> Can someone explain the difference between backticks and system when
> evaluated in this if statement:
>
The difference really isn't specific to this context, it is the inherent
difference between the two that is affecting t
Hi,
Can someone explain the difference between backticks and system when
evaluated in this if statement:
sub getDate {
print "start date\n";
if ( system("/bin/date") ) {
print "can't get date\n";
exit(2);
}
print "finish date\n";
}
Return
$rdiff command into a strong,
> as well as get an exit code for it?
>
> Is this a backticks one?
>
> Gavin.
>
Generally if you want the output you want backticks. The exit code is
still available from C<$?>. And can be extracted the same as described in,
perldoc perlvar
Sorry, this has been asked a million times, as I just foun din the
archives and perlmonk.
Don't bother replying :-)
Gavin.
--
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL
this a backticks one?
Gavin.
--
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
Cc:
Subject: Re: Backticks alternative?
> $exec = "ls -l";
> $src = syscall($exec);
>
> sub syscall{
>return `$_[0]`;
> }
>
> should work.
Sh
Gunnar Hjalmarsson wrote:
Hmm.. Is there any situation when it's motivated to do that instead
of using backticks (or the qr// operator)?
Sorry.. I meant the qx// operator.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED
Prasanna Kothari wrote:
Gohaku wrote:
After using backticks to retrieve executable output,
I would like to know if there is a backtick alternative.
Try this
local *CMD;
$cmd = "dir";
open(CMD,"$cmd 2>&1|")|| die "Could not open file handle\n";
while()
Tim Johnson wrote:
Gohaku wrote:
After using backticks to retrieve executable output, I would like
to know if there is a backtick alternative.
If you want the exact same function as the backticks, why not just
make a small subroutine?
Maybe because it's unnecessary, since there already
Suresh Pasupula wrote:
Gohaku wrote:
After using backticks to retrieve executable output,
I would like to know if there is a backtick alternative.
You can use in the following way:
$exec = "ls -l";
$src = system($exec);
Please read "perldoc -f system" to find out why you typi
On Tue, 6 Jul 2004 00:28:57 -0400, gohaku <[EMAIL PROTECTED]> wrote:
> Hi everyone,
> After using backticks to retrieve executable output,
> I would like to know if there is a backtick alternative.
>
> For example, to get a File Listing on a Unix-based system,
> I will
On Monday 05 July 2004 21:28, gohaku wrote:
>
> Hi everyone,
Hello,
> After using backticks to retrieve executable output,
> I would like to know if there is a backtick alternative.
>
> For example, to get a File Listing on a Unix-based system,
> I will do the usual:
>
&
Try this
local *CMD;
$cmd = "dir";
open(CMD,"$cmd 2>&1|")|| die "Could not open file handle\n";
while() {
print $_,"\n";
}
close(CMD) || die "Could not close $cmd $!\n";
The program is printing to STDOUT.
--Prasanna
gohaku wrote:
Hi ever
If you want the exact same function as the backticks, why not just make a small
subroutine?
#
$exec = "ls -l";
$src = syscall($exec);
sub syscall{
return `$_[0]`;
}
#
should work.
-Original Message-
From: gohaku [mai
You can use in the following way:
$exec = "ls -l";
$src = system($exec);
-Original Message-
From: gohaku [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 06, 2004 9:59 AM
To: Perl Beginners
Subject: Backticks alternative?
Hi everyone,
After using backticks to retrieve executa
Hi everyone,
After using backticks to retrieve executable output,
I would like to know if there is a backtick alternative.
For example, to get a File Listing on a Unix-based system,
I will do the usual:
$exec = "ls -l";
$src = `$exec`;
Unfortunately, I find the ` to be unreadable and
On Fri, 02 Apr 2004 16:22:51 +0200
Martin Lercher <[EMAIL PROTECTED]> wrote:
> >ps uf
> 2740 pts/7S 0:00 \_ /usr/bin/perl ./t5.pl
> 2894 pts/7T 0:00 \_ ls
> 2895 pts/7Z 0:00 \_ [ls ]
Strange. It looks like ls has forked a copy of itself and is wai
Martin Lercher wrote:
#!/usr/bin/perl
for (my $j=0;$j<1;$j++) {
my $result = `ls` ;
print $result ;
}
>ps uf
2740 pts/7S 0:00 \_ /usr/bin/perl ./t5.pl
2894 pts/7T 0:00 \_ ls
2895 pts/7Z 0:00 \_ [ls ]
I don't think that is Perl; the O
Hi,
I'm trying to repeatedly call some external program from Perl using
backticks. This works fine for ~30 rounds, but then the program stops
doing anything, with a process hanging around (apparently Perl
ignores its dead child?). A simple example is this:
#!/usr/bin/perl
for (my $j
[EMAIL PROTECTED] wrote:
this does have to run on multiple servers so that is a concern, but all
servers are identical in everyway
This is where Yoda sez: "So sure are you?"
--
_Sx_ http://youve-reached-the.endoftheinternet.org/ _
perldoc -qa.a | perl -lpe '($_)=m("(.*)")' | grep Martian
--
On Mar 23, 2004, at 9:12 AM, [EMAIL PROTECTED] wrote:
>> Hello,
>>
>> I have some code that is using backticks, executing commands on the
>> korn
>> shell.(if that matters). Most work as expected and i get the output
>> of the
>> shell command ass
> Hello,
>
> I have some code that is using backticks, executing commands on the korn
> shell.(if that matters). Most work as expected and i get the output
of the
> shell command assigned to the variable left of the argument, like with
this
> ls command and
On Mar 23, 2004, at 9:12 AM, [EMAIL PROTECTED] wrote:
Hello,
I have some code that is using backticks, executing commands on the
korn
shell.(if that matters). Most work as expected and i get the output
of the
shell command assigned to the variable left of the argument, like with
this
ls
Hello,
I have some code that is using backticks, executing commands on the korn
shell.(if that matters). Most work as expected and i get the output of the
shell command assigned to the variable left of the argument, like with this
ls command and 'db2 connect' command.
$is_
Nikola Janceski <[EMAIL PROTECTED]> wrote:
>>
>> is there a way to use the PROGRAM LIST format for backticks
>> or open the same way you can for exec and system?
>
> I have found one work around, but I was hoping there would be
> some other way..
>
> p
From: Nikola Janceski [mailto:nikola_janceski@;summithq.com]
> Sent: Thursday, November 07, 2002 11:21 AM
> To: Beginners (E-mail)
> Subject: command help using open/backticks
>
>
> Here's my situation...
>
> I have a command I need to run and parse the output of, BUT
> the
Here's my situation...
I have a command I need to run and parse the output of, BUT the command is
longer than 255 characters.
is there a way to use the PROGRAM LIST format for backticks or open the same
way you can for exec and system?
Nikola Janceski
There is no great concurrence be
Thanks George,
I will try ...
José.
-Original Message-
From: George Schlossnagle [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 29, 2002 10:27 AM
To: NYIMI Jose (BMB)
Cc: [EMAIL PROTECTED]
Subject: Re: Avoid using backticks
You can use the File::Find module. It even has a find2perl
2 10:15 AM
To: [EMAIL PROTECTED]; NYIMI Jose (BMB)
Subject: Re: Avoid using backticks
You should be able to do it with
opendir (to open directories and browse the contents)
and
unlink (to delete files)
take a look at the man pages for those two to get you started, if you're still
struggling ju
You can use the File::Find module. It even has a find2perl utility for
taking the work of writing a matching subroutine out:
Then you get something like
#!/usr/local/bin/perl -w
use strict;
use FindBin qw{$Bin};
use File::Find;
find(\&wanted, $Bin);
sub wanted {
(my ($dev,$ino,$mode,$nl
You should be able to do it with
opendir (to open directories and browse the contents)
and
unlink (to delete files)
take a look at the man pages for those two to get you started, if
you're still struggling just ask again.
HTH
Nigel
>>> "NYIMI Jose (BMB)" <[EMAIL PROTECTED]> 07/29/02 08:37am
Hello,
I would like to clean up my logfile directory by removing files that are older than 7
days.
So I wrote something like:
/user/local/bin/perl -w
use strict;
use FindBin qw($Bin);
#
`find $Bin -mtime +7 -name '*.log' -exec rm {} \;`;
#
__END__
My question is: how can I use perl's synthax i
Harvey Quamen wrote:
>
> Hello all:
Hello,
> I'm working my way through "Learning Perl" (3rd ed) and got stuck in
> ch 14 (Process Management, pages 201-202 actually, to be specific)
> where the "date" command is is opened through a filehandle with a
> piped open. Just toying around to see how
Hello all:
I'm working my way through "Learning Perl" (3rd ed) and got stuck in
ch 14 (Process Management, pages 201-202 actually, to be specific)
where the "date" command is is opened through a filehandle with a
piped open. Just toying around to see how it worked, I put it in a
loop and was
$pat = `echo \%path\%`
This should direct output of the echo command to $path variable.
But this is not happening,but it displays output to the screen instead.
I ran this script in around 200 systems(windows 95 + windows 98),130 out of
them produced the required output ,as remining failed.
Wha
-
From: "Veeraraju_Mareddi" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, November 22, 2001 9:36 AM
Subject: Backticks Command Execution
> $pat = `echo \%path\%`
>
> This should direct output of the echo command to $path variable
01, Kingsbury, Michael wrote:
>
> > Is there a way to export perl variables for use when run in backticks?
>
> What do you mean? Variables interpolate inside of backticks (unless you
> are silly enought to do qx'', and then they won't).
>
> -- Br
> -Original Message-
> From: Gary L. Armstrong [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 05, 2001 3:09 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Env for Cmds run in backticks
>
>
> I would guess you are actually asking about exportin
a lot with env vars, and shells are all different, mileage may
vary, etc.
-=GLA=-
-Original Message-
From: Kingsbury, Michael [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 04, 2001 2:50 PM
To: '[EMAIL PROTECTED]'
Subject: Env for Cmds run in backticks
Is there a way to expo
On Thu, 4 Oct 2001, Kingsbury, Michael wrote:
> Is there a way to export perl variables for use when run in backticks?
What do you mean? Variables interpolate inside of backticks (unless you
are silly enought to do qx'', and then they won&
On Mon, Jul 02, 2001 at 04:06:47PM -0300, Silvio Luis Leite Santana wrote:
> It seems the backtick operator calls the shell, otherwise
> it wouldn't be able to redirect output to file saida.
Backticks aren't the only thing that uses the shell, nor do they always use
the shell
Hi all
I've just did that, and it worked:
[silvio@tico perl]$ cat saida
cat: saida: No such file or directory
[silvio@tico perl]$ perl -e '$x = `pwd>saida`; print "[$x]\n";'
[]
[silvio@tico perl]$ cat saida
/home/silvio/perl
It seems the backtick operator calls the shell, otherwise
it wouldn't b
--- "Cron, Daniel" <[EMAIL PROTECTED]> wrote:
> It seems that when I use backticks to kick off a job in the
> background, my perl script waits until the background job finishes.
> But it seems that the system command actually kicks things off and
> moves on.
[snip]
It seems that when I use backticks to kick off a job in the background, my
perl script waits until the background job finishes.
But it seems that the system command actually kicks things off and moves on.
Here a perl script which demonstrates this behavior:
#!/opt/local/bin/perl -w
use strict
> "Timothy" == Timothy Kimball <[EMAIL PROTECTED]> writes:
Timothy> As for always getting that weird error message from $!, I always
Timothy> get "Illegal seek" on my machine.
You should never look at $! unless immediately following a *failed*
system-related call. A successful call doesn't
EMAIL PROTECTED]'
Subject: RE: $! after using backticks
>I want to check that a backtick command has executed OK. I thought I could
>do that by looking at the $! variable.
Check $?
This is Child exit status which is what you get when you spawn another
process with back ticks.
The $! is
Enter:
perldoc perlvar
and then look at the entries for $CHILD_ERROR ($?) and $ERRNO ($!).
There can be other issues about return values, but start with the above.
Ron Mitchell wrote:
: I want to check that a backtick command has executed OK. I thought I could
: do that by looking at the $! variable.
Check $? instead. This one's for pipes, backticks, & system() commands.
It's a fairly complex flag, with a lot of stuff in it, but briefly,
$?
>I want to check that a backtick command has executed OK. I thought I could
>do that by looking at the $! variable.
Check $?
This is Child exit status which is what you get when you spawn another
process with back ticks.
The $! is the ERRNO (or Error string depending on context) for the last
sy
$! = No such file or directory
$! always seems to be set to this message no matter what command is in the
backticks. I want to be able to determine when the command really did go
wrong. How can I do it?
Thanks,
Ron
73 matches
Mail list logo