Is it piped?

2007-06-09 Thread Beau Cox
Hi - From within a perl script, how can I deternine if STDxxx is from/to a pipe? Aloha = Beau;

Re: Is it piped?

2007-06-09 Thread Tom Phoenix
On 6/9/07, Beau Cox [EMAIL PROTECTED] wrote: From within a perl script, how can I deternine if STDxxx is from/to a pipe? You probably want a filetest. Maybe you want -p, which returns true if the filehandle is a pipe: my $piped_output = -p STDOUT; my $piped_input = -p STDIN; Many

Providing STDIN to a PIPEd call to perl

2006-07-05 Thread Kevin Viel
I call a perl script from SAS using a pipe. The file on which the script acts changes. Is there a way to provide the file name to the script using STDIN on the command line? The SAS call looks like: filename ABI pipe perl C:/base.ps ; For now, I altered the script to read a text file

Re: Providing STDIN to a PIPEd call to perl

2006-07-05 Thread Mr. Shawn H. Corey
Kevin Viel wrote: I call a perl script from SAS using a pipe. The file on which the script acts changes. Is there a way to provide the file name to the script using STDIN on the command line? The SAS call looks like: filename ABI pipe perl C:/base.ps ; For now, I altered the script to

Re: Providing STDIN to a PIPEd call to perl

2006-07-05 Thread Kevin Viel
Mr. Shawn H. Corey wrote: Kevin Viel wrote: I call a perl script from SAS using a pipe. The file on which the script acts changes. Is there a way to provide the file name to the script using STDIN on the command line? The SAS call looks like: filename ABI pipe perl C:/base.ps ; For now, I

Re: Providing STDIN to a PIPEd call to perl

2006-07-05 Thread Mr. Shawn H. Corey
Kevin Viel wrote: That should work, but I cannot use the keyboard to provide the STDIN. Instead I was hoping for something like: filename ABI pipe perl C:/base.ps file.ab1 ; ^ Thanks, Kevin How about? my $filename = ; chomp $filename;

Re: Providing STDIN to a PIPEd call to perl

2006-07-05 Thread Chad Perrin
On Wed, Jul 05, 2006 at 11:31:55AM -0500, Kevin Viel wrote: Mr. Shawn H. Corey wrote: Kevin Viel wrote: I call a perl script from SAS using a pipe. The file on which the script acts changes. Is there a way to provide the file name to the script using STDIN on the command line? The SAS

Re: Providing STDIN to a PIPEd call to perl

2006-07-05 Thread Kevin Viel
Chad Perrin wrote: On Wed, Jul 05, 2006 at 11:31:55AM -0500, Kevin Viel wrote: Mr. Shawn H. Corey wrote: Kevin Viel wrote: I call a perl script from SAS using a pipe. The file on which the script acts changes. Is there a way to provide the file name to the script using STDIN on the

two way piped open

2005-08-24 Thread Bryan R Harris
I'd like to open 2-way pipe to a tool that we have here. It's called yprtool and once it's open, you give it 3 numbers to its STDIN and it spits out 3 numbers to its STDOUT. It stays open until you ctrl-c it. What's the correct syntax for opening something like this? This doesn't work:

Re: two way piped open

2005-08-24 Thread Wiggins d'Anconia
Bryan R Harris wrote: I'd like to open 2-way pipe to a tool that we have here. It's called yprtool and once it's open, you give it 3 numbers to its STDIN and it spits out 3 numbers to its STDOUT. It stays open until you ctrl-c it. What's the correct syntax for opening something like

Re: two way piped open

2005-08-24 Thread Bryan R Harris
That does it, thanks, Wiggins! - B Bryan R Harris wrote: I'd like to open 2-way pipe to a tool that we have here. It's called yprtool and once it's open, you give it 3 numbers to its STDIN and it spits out 3 numbers to its STDOUT. It stays open until you ctrl-c it. What's the

Re: two way piped open

2005-08-24 Thread Bryan R Harris
And a follow-on question: Any idea why I have to send the yprtool two \ns instead of one to make it work? With just one it hangs... On the command line, it definitely works with just one. ** ($y,$p,$r) = (split(' ', $lines[15]))[11..13]; use IPC::Open2;

RE: two way piped open

2005-08-24 Thread Timothy Johnson
24, 2005 1:51 PM To: Beginners Perl Subject: Re: two way piped open And a follow-on question: Any idea why I have to send the yprtool two \ns instead of one to make it work? With just one it hangs... On the command line, it definitely works with just one. snip -- To unsubscribe, e-mail

Re: two way piped open

2005-08-24 Thread Bryan R Harris
. -Original Message- From: Bryan R Harris [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 24, 2005 1:51 PM To: Beginners Perl Subject: Re: two way piped open And a follow-on question: Any idea why I have to send the yprtool two \ns instead of one to make it work? With just

Re: two way piped open

2005-08-24 Thread Bryan R Harris
. Try selecting your file handle and then setting $| to 1. That way Perl should send your output immediately. -Original Message- From: Bryan R Harris [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 24, 2005 1:51 PM To: Beginners Perl Subject: Re: two way piped open

re: Piped input

2004-05-10 Thread William Black
Hello I have the following driver script that calls two perl scripts to run them asyn. The driver calls the open command for both scripts but the pgm just hangs and never finishes. Does anyone know why? Driver: open (DAL,|C:\temp7\backup\temp1.pl); open (DAL,|C:\temp7\backup\temp2.pl); while

RE: Piped input

2004-05-10 Thread NandKishore.Sagi
The file handlers are both DAL. Change the file handler names. -Original Message- From: William Black [mailto:[EMAIL PROTECTED] Sent: Monday, May 10, 2004 8:50 AM To: [EMAIL PROTECTED] Subject: re: Piped input Hello I have the following driver script that calls two perl scripts

Re: How to determine if STDIN has piped data?

2004-04-03 Thread Adam
Bryan, The scope of this conversation seems beyond my ability, but I think I can answer you're question - I'm sure someone will correct me if I'm wrong :) You're looking to put together scripts that act like typical command-line commands like `ls` or `cat`. I use the magic of the diamond

Re: How to determine if STDIN has piped data?

2004-04-02 Thread Daniel Staal
--As of Thursday, April 1, 2004 11:48 AM +0159, Morten Liebach is alleged to have said: Strangely, I find that we almost always want our scripts to act this way. If any files or data is passed to the script, then it uses it. Otherwise, it prints usage instructions (since we'd rather not have man

Re: How to determine if STDIN has piped data?

2004-04-02 Thread WC -Sx- Jones
Daniel Staal wrote: Even better: you can run pod2man on the program/pod file, and end up with a man page. Put that in the standard man search path and the user can type man $scriptname as if it were any other unix program. True... Also, make sure you regularly do catman and/or updatedb

Re: How to determine if STDIN has piped data?

2004-04-01 Thread Robin Sheat
On Wed, Mar 31, 2004 at 11:58:58PM -0700, Bryan Harris wrote: =) I was referring to a socket. I couldn't think of any place where I might need to use one. As an example, I have a neural network system I made in Java. It accepts commands over a network socket. I then have a Perl program

Re: How to determine if STDIN has piped data?

2004-04-01 Thread Morten Liebach
On 2004-03-30 21:35:21 -0700, Bryan Harris wrote: On Mon, 29 Mar 2004 00:38:50 -0700 Bryan Harris [EMAIL PROTECTED] wrote: Alternatively, you can use the '-t' operator: exit 0 if -t STDIN I've been waiting for this for a LONG time, thanks Smoot. No problem. It took

Re: How to determine if STDIN has piped data?

2004-04-01 Thread Bryan Harris
Alternatively, you can use the '-t' operator: exit 0 if -t STDIN I've been waiting for this for a LONG time, thanks Smoot. No problem. It took me a while to find the correct operator as well. Please keep in mind that doing this breaks the de facto Unix standard for filters. A

Re: How to determine if STDIN has piped data?

2004-03-31 Thread Smoot Carl-Mitchell
On Tue, 30 Mar 2004 21:35:21 -0700 Bryan Harris [EMAIL PROTECTED] wrote: Please keep in mind that doing this breaks the de facto Unix standard for filters. A simply command which is a filter (e.g takes input from STDIN and sends output to STDOUT) is written without any consideration

Re: How to determine if STDIN has piped data?

2004-03-31 Thread Bryan Harris
By the way, what's a socket? Usually, a network protocol end-point which for most I/O purposes looks like a file handle. Instead of reading or writing from a file, the program reads or writes a socket which is typically connected to another program via a network protocol which is either

Re: How to determine if STDIN has piped data?

2004-03-31 Thread WC -Sx- Jones
Bryan Harris wrote: So an example use of a socket would be, say, a script that would listen on a socket (?) and notify me in response to a message from a particular cgi being executed on my webserver? I guess I'm not sure where anyone would use this... A socket or your example? Your example can

Re: How to determine if STDIN has piped data?

2004-03-31 Thread Bryan Harris
Bryan Harris wrote: So an example use of a socket would be, say, a script that would listen on a socket (?) and notify me in response to a message from a particular cgi being executed on my webserver? I guess I'm not sure where anyone would use this... A socket or your example? =) I

Re: How to determine if STDIN has piped data?

2004-03-30 Thread Bryan Harris
On Mon, 29 Mar 2004 00:38:50 -0700 Bryan Harris [EMAIL PROTECTED] wrote: Alternatively, you can use the '-t' operator: exit 0 if -t STDIN I've been waiting for this for a LONG time, thanks Smoot. No problem. It took me a while to find the correct operator as well. Please keep

Re: How to determine if STDIN has piped data?

2004-03-29 Thread Smoot Carl-Mitchell
On Mon, 29 Mar 2004 00:38:50 -0700 Bryan Harris [EMAIL PROTECTED] wrote: Alternatively, you can use the '-t' operator: exit 0 if -t STDIN I've been waiting for this for a LONG time, thanks Smoot. No problem. It took me a while to find the correct operator as well. Please keep in

Re: How to determine if STDIN has piped data?

2004-03-29 Thread Keith P. Boruff
Bryan Harris wrote: Alternatively, you can use the '-t' operator: exit 0 if -t STDIN I've been waiting for this for a LONG time, thanks Smoot. - B Excellent! Worked like a charm! This is exactly the kind of thing I was looking for. Thanks! Keith P. Boruff -- To unsubscribe,

How to determine if STDIN has piped data?

2004-03-28 Thread Keith P. Boruff
is to allow the script to read data that's piped in but quit if there is none. In other words, how do I get this code: while(STDIN) { print $_ . \n; } not to even loop at all if it has to wait for a human being to enter data? I dealt with this issue in C but it's been some time ago. Thanks

Re: How to determine if STDIN has piped data?

2004-03-28 Thread Smoot Carl-Mitchell
On Sun, 28 Mar 2004 20:01:18 -0500 Keith P. Boruff [EMAIL PROTECTED] wrote: What I'm trying to do though is to allow the script to read data that's piped in but quit if there is none. In other words, how do I get this code: while(STDIN) { print $_ . \n; } You can use the POSIX

Re: How to determine if STDIN has piped data?

2004-03-28 Thread drieux
On Mar 28, 2004, at 5:01 PM, Keith P. Boruff wrote: [..] In other words, how do I get this code: while(STDIN) { print $_ . \n; } not to even loop at all if it has to wait for a human being to enter data? [..] actually the simplest trick would be say: use IO::Handle; my $io =

Re: How to determine if STDIN has piped data?

2004-03-28 Thread Bryan Harris
Alternatively, you can use the '-t' operator: exit 0 if -t STDIN I've been waiting for this for a LONG time, thanks Smoot. - B -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response

Re: piped system commands

2004-01-04 Thread deb
John, thanks for the perl approach. Mustn't forget about that! deb At 20:59:59, on 01.02.04: Cracks in my tinfoil beanie allowed John W. Krahn to seep these bits into my brain:, Deb wrote: I want to run a command inside a script. From the shell, here's the command: % ps -ef |

Re: piped system commands

2004-01-02 Thread John W. Krahn
Deb wrote: I want to run a command inside a script. From the shell, here's the command: % ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk '{print $2}' 19460 open PS, 'ps -ef |' or die Cannot open pipe from 'ps -ef' $!; my $pid; while ( PS ) { next unless

scripted piped system commands

2003-12-31 Thread deb
Happy Almost New Year! I want to run a unix system command inside a script. From the shell, here's the command(s): % ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk '{print $2}' 19460 What is returned is the pid of the process being grep'd. But, when I put this into a

Re: piped system commands

2003-12-31 Thread deb
At 17:50:40, on 12.30.03: Cracks in my tinfoil beanie allowed Andrew Gaffney to seep these bits into my brain:, Try changing the $2 to \$2. Perl is interpolating $2 before it gets to bash, so bash sees /bin/awk '{print }'. -- Andrew, Ah!!! That was it. I should have seen that. Thanks

Re: piped system commands

2003-12-31 Thread deb
At 15:58:26, on 12.30.03: Cracks in my tinfoil beanie allowed Bakken, Luke to seep these bits into my brain:, Instead of the useless 'grep -v grep', do this: % ps -ef | egrep '[/]usr/lib/sendmail' | awk '{print $2}' Ah, yes, much cleaner. Old habits die hard. :-) But, when I put this

Re: piped system commands

2003-12-31 Thread drieux
On Dec 31, 2003, at 9:04 AM, deb wrote: Drieux, Vladimir??? yes, named after vladimir ilyich, it is my Sparc Box. :-) Thanks for the hints. :-) Personally I would be doing it with something like http://www.wetware.com/drieux/CS/Proj/Wetware_ps/ Which of course first started out as

piped system commands

2003-12-30 Thread deb
Happy Almost New Year! I want to run a command inside a script. From the shell, here's the command: % ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk '{print $2}' 19460 What is returned is the pid of the process being grep'd. But, when I put this into a test script,

Re: piped system commands

2003-12-30 Thread Andrew Gaffney
deb wrote: Happy Almost New Year! I want to run a command inside a script. From the shell, here's the command: % ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk '{print $2}' 19460 What is returned is the pid of the process being grep'd. But, when I put this into a test

RE: piped system commands

2003-12-30 Thread Bakken, Luke
I want to run a command inside a script. From the shell, here's the command: % ps -ef | /bin/egrep '/usr/lib/sendmail' | /bin/grep -v grep | /bin/awk '{print $2}' 19460 Instead of the useless 'grep -v grep', do this: % ps -ef | egrep '[/]usr/lib/sendmail' | awk '{print $2}' But, when

Re: piped system commands

2003-12-30 Thread drieux
On Dec 30, 2003, at 3:54 PM, deb wrote: Happy Almost New Year! [..] It seems to be only going as far as dropping off the grep, and not doing the awk '{print $2}'. I've tried this with the system() call, with the same results. What am I missing? :-( you have a shell interpret who to which

capture out put from piped process

2002-07-15 Thread Jon Howe
How do I capture the output from sendmail running under the -v switch back to my programme. The line I am using is - open (MAIL, |/usr/lib/sendmail -oi -t -v) or die cant fork proc to mail\n; regards Jon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail:

Re: capture out put from piped process

2002-07-15 Thread Daniel Gardner
Jon Howe wrote: How do I capture the output from sendmail running under the -v switch back to my programme. The line I am using is - open (MAIL, |/usr/lib/sendmail -oi -t -v) or die cant fork proc to mail\n; perldoc IPC::Open2 IPC::Run on cpan can do some clever stuff too -- Best

Re: capture out put from piped process

2002-07-15 Thread drieux
On Monday, July 15, 2002, at 04:03 , Jon Howe wrote: How do I capture the output from sendmail running under the -v switch back to my programme. The line I am using is - open (MAIL, |/usr/lib/sendmail -oi -t -v) or die cant fork proc to mail\n; if you really want to 'catch' that, then

Re: capture out put from piped process

2002-07-15 Thread Jenda Krynicky
From: Jon Howe [EMAIL PROTECTED] How do I capture the output from sendmail running under the -v switch back to my programme. The line I am using is - open (MAIL, |/usr/lib/sendmail -oi -t -v) or die cant fork proc to mail\n; The easier way is to pipe it into a temporary file: open