Solved

windows dos commands in Activestate Perl?

Posted on 2006-06-26
4
995 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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
how to extract data from a table into a fixed length file 10 49
collecting information 2 128
Awk Question 2 115
create a gui in perl 3 42
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 …
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now