Solved

windows dos commands in Activestate Perl?

Posted on 2006-06-26
4
997 Views
Last Modified: 2010-05-18
For example, I would like to run a exe file or I want to use the command "copy", how can I do that?

In linux, I know that I can use system("cp file1 file2"); are there any ways that I can run dos commands in Activestate Perl?
0
Comment
Question by:ecnalb
4 Comments
 
LVL 19

Accepted Solution

by:
Kim Ryan earned 150 total points
ID: 16989244
Yes, system commands will also work on windows. Just use windows DOS systnax instead of linux
system("copy file1 file2");

There is also a module to do this:

               use File::Copy;
 
               copy("file1","file2");
 
0
 
LVL 8

Expert Comment

by:Perl_Diver
ID: 16994560
I'd stick with perl functions whenever possible, but as teraplane has shown you it's very eay to use DOS commands from perl.

To run an application you can use:

system(run.exe);
qx/run.exe/; (same as beleow)
`run.exe`; (same as above)
exec(run.exe);

system() returns the exit code of the program, not the output.
qx// and `` (backtiks) return the output of the program.
exec() starts the application but then exits the perl script so never gets anything back from the application.

0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 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