Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

www.webdp.net, Event 9 IIS log failed to write entry, wwwxxx jeffs, Catastrophic failure Unexpected method call sequence. 0x8000ffff (-2147418113)., ksh lock a file, [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_DBC failed, sed: -e expression #1, char 1: unterminated address regex, procmail + change subject, w2ksp4.exe download, /proc/kallsyms format

Links

XODOX
Impressum

#1: print output on console at runtime

Posted on 2011-07-13 07:46:15 by Irfan Sayed

--0-1078255183-1310535975=:41973
Content-Type: text/plain; charset=us-ascii

hi,

i need to print the output of a command on the console at runtime
lets say, i need to execute find command .as of now , what i am doing is ,

@cmd= `find . -name "abc"`;
print "@cmd\n";

now what happens is, once the command completed then it will send entire output to @cmd
and then entire output gets printed to console in one shot

instead of that , i need output to be printed as it progresses


plz suggest


regards
irfan
--0-1078255183-1310535975=:41973--

Report this message

#2: Re: print output on console at runtime

Posted on 2011-07-13 08:14:00 by Chandrashekar Bhat

--20cf300fb095b2405b04a7ed5399
Content-Type: text/plain; charset=ISO-8859-1

You can use system command inside perl

system(" find . -iname 'abc'");

--
Shekar

On Wed, Jul 13, 2011 at 11:16 AM, Irfan Sayed <irfan_sayed2002@yahoo.com>wrote:

> hi,
>
> i need to print the output of a command on the console at runtime
> lets say, i need to execute find command .as of now , what i am doing is ,
>
> @cmd= `find . -name "abc"`;
> print "@cmd\n";
>
> now what happens is, once the command completed then it will send entire
> output to @cmd
> and then entire output gets printed to console in one shot
>
> instead of that , i need output to be printed as it progresses
>
>
> plz suggest
>
>
> regards
> irfan

--20cf300fb095b2405b04a7ed5399--

Report this message

#3: Re: print output on console at runtime

Posted on 2011-07-13 08:28:07 by Jim Gibson

At 10:46 PM -0700 7/12/11, Irfan Sayed wrote:
>hi,
>
>i need to print the output of a command on the console at runtime
>lets say, i need to execute find command .as of now , what i am doing is ,
>
>@cmd= `find . -name "abc"`;
>print "@cmd\n";
>
>now what happens is, once the command completed then it will send
>entire output to @cmd
>and then entire output gets printed to console in one shot
>
>instead of that , i need output to be printed as it progresses

You have two choices that I can think of:

1. Use the Perl module File::Find instead of forking an external
process to run the operating system's find command.

See 'perldoc File::Find'.

Example (untested):

use File::Find;
find( sub{
return unless $_ eq 'abc';
print qq($File::Find::name\n)
}, q(.)
);

2. Fork the find program using open and a mode parameter of '-|'
instead of back-quotes.

See 'perldoc -f open'.

Example (untested):

open( my $find, '-|', q(find . -name "abc")) or die("Can't fork find
program: $!");
while( <$find> ) {
print;
}

--
Jim Gibson
Jim@Gibson.org

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Report this message

#4: Re: print output on console at runtime

Posted on 2011-07-13 08:52:58 by jwkrahn

Irfan Sayed wrote:
> hi,

Hello,


> i need to print the output of a command on the console at runtime
> lets say, i need to execute find command .as of now , what i am doing is ,
>
> @cmd= `find . -name "abc"`;
> print "@cmd\n";
>
> now what happens is, once the command completed then it will send entire output to @cmd
> and then entire output gets printed to console in one shot
>
> instead of that , i need output to be printed as it progresses

open my $PIPE, '-|', 'find', ',', '-name', 'abc' or die "Cannot open
pipe from 'find' because: $!:

while ( <$PIPE> ) {
print;
}

close $PIPE or warn $! ? "Error closing 'find' pipe: $!"
: "Exit status $? from 'find'";



John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Report this message

#5: Re: print output on console at runtime

Posted on 2011-07-13 09:27:52 by Irfan Sayed

--0-1621167944-1310542072=:9844
Content-Type: text/plain; charset=us-ascii

thanks John and Jim
but, is this solution is applicable to only "find" command ?
if i change the command to some other system command , will this solution work?

plz suggest



________________________________
From: Jim Gibson <jimsgibson@gmail.com>
To: Perl Beginners <beginners@perl.org>
Sent: Wednesday, July 13, 2011 12:00 PM
Subject: Re: print output on console at runtime




You chose to allow Jim Gibson (jimsgibson@gmail.com) even though this message failed authentication
Click to disallow
--0-1621167944-1310542072=:9844--

Report this message

#6: Re: print output on console at runtime

Posted on 2011-07-13 16:45:18 by Jim Gibson

At 12:27 AM -0700 7/13/11, Irfan Sayed wrote:
>thanks John and Jim
>but, is this solution is applicable to only "find" command ?

No.

>if i change the command to some other system command , will this
>solution work?

Yes.

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Report this message

#7: Re: print output on console at runtime

Posted on 2011-07-28 08:36:45 by Irfan Sayed

--0-1377588390-1311835005=:31544
Content-Type: text/plain; charset=us-ascii

can this be happen if command needs to be executed on remote machine and the output needs to be forked on the local console at runtime


please suggest


regards
irfan



________________________________
From: Jim Gibson <jimsgibson@gmail.com>
To: Perl Beginners <beginners@perl.org>
Sent: Wednesday, July 13, 2011 12:00 PM
Subject: Re: print output on console at runtime




You chose to allow Jim Gibson (jimsgibson@gmail.com) even though this message failed authentication
Click to disallow
--0-1377588390-1311835005=:31544--

Report this message

#8: Re: print output on console at runtime

Posted on 2011-07-28 16:05:48 by Irfan Sayed

--0-1030871890-1311861948=:59848
Content-Type: text/plain; charset=us-ascii

further,

i am executing following command using open

open $frk, "devenv /rebuild release ReusableU.sln /useenv 2>&1 |" or die "Couldn't execute program: $!";
now i need to capture the exit status of this command

i tried with $? but it does not contain the exit status

please suggest


regards
irfan



________________________________
From: Irfan Sayed <irfan_sayed2002@yahoo.com>
To: Jim Gibson <jimsgibson@gmail.com>; Perl Beginners <beginners@perl.org>
Sent: Thursday, July 28, 2011 12:06 PM
Subject: Re: print output on console at runtime


can this be happen if command needs to be executed on remote machine and the output needs to be forked on the local console at runtime


please suggest


regards
irfan



________________________________
From: Jim Gibson <jimsgibson@gmail.com>
To: Perl Beginners <beginners@perl.org>
Sent: Wednesday, July 13, 2011 12:00 PM
Subject: Re: print output on console at runtime




You chose to allow Jim Gibson (jimsgibson@gmail.com) even though this message failed authentication
Click to disallow
--0-1030871890-1311861948=:59848--

Report this message