[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

windows dos commands in Activestate Perl?

Posted on 2006-06-26
4
Medium Priority
?
1,017 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 600 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Six Sigma Control Plans

650 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