activeperl@listserv.ActiveState.com
[Top] [All Lists]

RE: To Run System Command

Subject: RE: To Run System Command
From: "Gardner, Sam"
Date: Fri, 4 Mar 2005 09:35:16 -0500

You may (depending on your needs) even like:

my $my_dir = 'home/your_dir';

system('cd $your_dir');  ##Note that backticks capture output -- using the 
@files = `dir *.txt /b`; ##"system" will be faster if
                                ##you don't need the return

## now, you have your files in an array

##Note that you could also use the perl-native (below)
##for the same effect, and not depend on shelling out your command

@files = glob('*.txt');
print join ',', @files;

Sam Gardner

GTO Application Development

Keefe, Bruyette & Woods, Inc.

212-887-6753





-----Original Message-----
From: Murugavel Chidambaram [mailto:murugavel.chidambaram@xxxxxx]
Sent: Friday, March 04, 2005 1:56 AM
To: Satish.Waghmare
Cc: activeperl-bounces@xxxxxxxxxxxxxxxxxxxxxxxx; activeperl@xxxxxxxxxxxxxxxxxxxxxxxx
Subject: Re: To Run System Command


Hi,

Try this way,

my $my_dir = 'home/your_dir';

`cd $your_dir`;
`dir *.txt /b > a.dat`;


Regards

C.M





Satish.Waghmare@xxxxxxxxxxxxx
Sent by: activeperl-bounces@xxxxxxxxxxxxxxxxxxxxxxxx
03/04/2005 03:43 PM
 
        To:     activeperl-bounces@xxxxxxxxxxxxxxxxxxxxxxxx
        cc:     activeperl@xxxxxxxxxxxxxxxxxxxxxxxx
        Subject:        To Run System Command


Hi :
 
I'm using ActiveState PERL 5.8 on Windows Platform.
 
I want to know about How to run a DOS command through a PERL script. I want to run a below DOS commmand and then read the result from the file

it has created.
Command--     dir *.txt /b > a.dat
Kindly please help me.
Thank You
Regards
~Satish
 
 _______________________________________________
ActivePerl mailing list
ActivePerl@xxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


_______________________________________________
ActivePerl mailing list
ActivePerl@xxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
ActivePerl mailing list
ActivePerl@xxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
<Prev in Thread] Current Thread [Next in Thread>