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
Solved

windows dos commands in Activestate Perl?

Posted on 2006-06-26
4
998 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how do I grep for a specfic DNS record in a directory 3 48
perl script help 12 105
Port 80 requests 16 100
perl syntax 3 16
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.…
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…

828 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