Hi -
From within a perl script, how can I deternine if STDxxx is from/to a pipe?
Aloha = Beau;
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
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
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
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
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;
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
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
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:
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
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
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;
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
.
-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
.
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
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
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
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
--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
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
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
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
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
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
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
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
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
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
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
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,
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
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
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 =
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
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 |
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
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
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
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
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
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,
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
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
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
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:
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
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
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
48 matches
Mail list logo