backticks

2006-08-19 Thread John Ackley
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

backticks

2001-07-02 Thread Silvio Luis Leite Santana
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

using backticks

2006-07-09 Thread Mahdi A Sbeih
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

Re: backticks

2006-08-19 Thread Tom Phoenix
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

Re: backticks

2006-08-19 Thread John Ackley
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

Re: backticks

2006-08-19 Thread Tommy Nordgren
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

Re: backticks

2006-08-19 Thread Ken Foskey
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

Re: backticks

2006-08-20 Thread John Ackley
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

Re: backticks

2006-08-20 Thread John Ackley
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

Re: backticks

2006-08-20 Thread John W. Krahn
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

using backticks

2006-10-06 Thread john wright
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

Re: backticks

2001-07-02 Thread Michael Fowler
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

Backticks alternative?

2004-07-05 Thread gohaku
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

qx() vs backticks

2009-04-19 Thread R. Hicks
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/

system vs. backticks

2010-05-18 Thread pauldkline
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.

system v backticks

2005-07-27 Thread Keenan, Greg John (Greg)** CTR **
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

backticks in s///?

2005-09-17 Thread Bryan Harris
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

Re: using backticks

2006-07-09 Thread Rob Dixon
: $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

Re: using backticks

2006-07-09 Thread Mahdi A Sbeih
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

Re: using backticks

2006-10-06 Thread Rob Dixon
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

Re: using backticks

2006-10-06 Thread John W. Krahn
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

Avoid using backticks

2002-07-29 Thread NYIMI Jose (BMB)
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

RE: Backticks alternative?

2004-07-05 Thread suresh.pasupula
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

RE: Backticks alternative?

2004-07-05 Thread Tim Johnson
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

Re: Backticks alternative?

2004-07-05 Thread Prasanna Kothari
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

Re: Backticks alternative?

2004-07-06 Thread John W . Krahn
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: > &

Re: Backticks alternative?

2004-07-06 Thread Brian Eable
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

Re: Backticks alternative?

2004-07-06 Thread Gunnar Hjalmarsson
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

Re: Backticks alternative?

2004-07-06 Thread Gunnar Hjalmarsson
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

Re: Backticks alternative?

2004-07-06 Thread Gunnar Hjalmarsson
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()

Re: Backticks alternative?

2004-07-06 Thread Gunnar Hjalmarsson
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

RE: Backticks alternative?

2004-07-06 Thread Tim Johnson
Cc: Subject: Re: Backticks alternative? > $exec = "ls -l"; > $src = syscall($exec); > > sub syscall{ >return `$_[0]`; > } > > should work. Sh

System or Backticks?

2004-09-02 Thread Gavin Henry
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>

$! after using backticks

2001-05-23 Thread Mitchell, Ronald
$! = 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

Backticks Command Execution

2001-11-22 Thread Veeraraju_Mareddi
$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

piping versus backticks

2002-01-08 Thread Harvey Quamen
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

Re: qx() vs backticks

2009-04-19 Thread Chas. Owens
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

Re: qx() vs backticks

2009-04-19 Thread Gunnar Hjalmarsson
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

Re: system vs. backticks

2010-05-19 Thread Dr.Ruud
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

Re: system vs. backticks

2010-05-19 Thread Rob Coops
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

Re: system vs. backticks

2010-06-10 Thread pauldkline
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

Re: system v backticks

2005-07-27 Thread Wiggins d'Anconia
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

Re: system v backticks

2005-07-27 Thread Jeff 'japhy' Pinyan
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

Re: Avoid using backticks

2002-07-29 Thread Nigel Peck
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

Re: Avoid using backticks

2002-07-29 Thread George Schlossnagle
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

RE: Avoid using backticks

2002-07-29 Thread NYIMI Jose (BMB)
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

RE: Avoid using backticks

2002-07-29 Thread NYIMI Jose (BMB)
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

backticks and variable assignment

2004-03-23 Thread jeffrey_n_Dyke
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_

Re: System or Backticks?

2004-09-02 Thread Wiggins d Anconia
$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

RE: $! after using backticks

2001-05-23 Thread Peter Cornelius
>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

Re: $! after using backticks

2001-05-23 Thread Timothy Kimball
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, $?

Re: $! after using backticks

2001-05-23 Thread Me
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.

RE: $! after using backticks

2001-05-23 Thread Mitchell, Ronald
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

Re: $! after using backticks

2001-05-23 Thread Randal L. Schwartz
> "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

Re: Backticks Command Execution

2001-11-22 Thread Mark Veinot
- 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

Re: piping versus backticks

2002-01-09 Thread John W. Krahn
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

command help using open/backticks

2002-11-07 Thread Nikola Janceski
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

Re: backticks and variable assignment

2004-03-23 Thread James Edward Gray II
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

Re: backticks and variable assignment

2004-03-23 Thread Wiggins d Anconia
> 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 &#x

RE: command help using open/backticks

2002-11-07 Thread Nikola Janceski
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

Re: command help using open/backticks

2002-11-07 Thread Steve Grazzini
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

Re: backticks and variable assignment - thanks

2004-03-23 Thread jeffrey_n_Dyke
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

Re: backticks and variable assignment - thanks

2004-03-23 Thread WC -Sx- Jones
[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 --

loop using backticks stalls after ~30x

2004-04-02 Thread Martin Lercher
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

Re: Env for Cmds run in backticks

2001-10-04 Thread Brett W. McCoy
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&

RE: Env for Cmds run in backticks

2001-10-04 Thread Gary L. Armstrong
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

RE: Env for Cmds run in backticks

2001-10-04 Thread Helmut Steinbach (QED)
> -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

Re: Env for Cmds run in backticks

2001-10-05 Thread Luke Bakken
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

Re: loop using backticks stalls after ~30x

2004-04-02 Thread WC -Sx- Jones
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

Re: loop using backticks stalls after ~30x

2004-04-02 Thread Smoot Carl-Mitchell
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

Running jobs in the background with backticks

2001-05-24 Thread Cron, Daniel
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

Re: System or Backticks? - Don't reply, searched archives :-)

2004-09-02 Thread Gavin Henry
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

Re: Running jobs in the background with backticks

2001-05-24 Thread Paul
--- "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]