Solved

Capture external command output line by line on Windows 98

Posted on 2003-11-20
8
306 Views
Last Modified: 2010-03-04
Hello,

I'm trying to Capture external command output and error line by line.
I wrote this example witch work excellent on Windows 2000:

open(PROC,"DIR 2>&1 |");
while(<PROC>) {
      print ("LINE:$_");
}
close(PROC);

But on Windows 98 it don't do nothing!
I'm user perl 5.6.1 activestate 625.

I need to display the output line by line and not all at once
so I can't use system command.

How can I implement it on windows 98 ?
0
Comment
Question by:addady
8 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 9791749

foreach (<*>) {
  print "LINE: $_";
}
0
 

Author Comment

by:addady
ID: 9796145
Tintin, I don't your answer ?
0
 
LVL 48

Expert Comment

by:Tintin
ID: 9802309
addady.

Did you leave the word "understand" out of your answer?

What I'm suggesting is that instead of relying on an external command to get a directory listing, use the Perl method of doing it for you.  That way your code is a lot more portable.

To invoke the dir command under Win98, I think you'd have to do something like "command.com dir", but that's not very portable, hence the solution I gave you.
0
 

Author Comment

by:addady
ID: 9845092
Please let me rewrite and update my question:

I'm trying to Capture external command output and error line by line.
There is no problem to implement it on windows 2000, but in Windows 98
you need a special shell.
The only shell that I found and it really work with is: stderr.exe*

This code is work fine on w98:

open(PROC,"stderr.exe $some_command |");
while(<PROC>) {
    print ("$_");
}
close(PROC);

But the point is that it fail when I'm specify full path for "stderr.exe"
(becuase I'm exe file using perlapp and --bind don't help)

For example:
open(PROC,"C:/dir_name/stderr.exe $some_command |");
while(<PROC>) {
    print ("$_");
}
close(PROC);

My questions are:
1) why can't I specify full path ?
2) do you know any alternative shell that work on Windows 98 using pipe.



* can be forun in: http://www.teaser.fr/~amajorel/stderr/stderr.txt

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 48

Expert Comment

by:Tintin
ID: 9889455
How about you include the error message to see why it is failing, ie:

open PROC,"C:/dir_name/stderr.exe $some_command |" or die :Can not run stderr.exe because $!\n";
0
 

Author Comment

by:addady
ID: 9892185
Hi Tintin,

It seens the it not "die" .  
There is no error and still the command is not exacuted.
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10093707
Nothing has happened on this question in more than 5 weeks. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
PAQ, refund points (good progress, but ultimately unresolved).

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 10148148
PAQed, with points refunded (200)

Computer101
E-E Admin
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Sending email via Perl on Windows 3 124
Syslog text file into database or into .CSV 19 91
Perl count the hash for print 4 156
perl script help 12 101
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now