Solved

windows dos commands in Activestate Perl?

Posted on 2006-06-26
4
1,000 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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…
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…

730 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