Solved

shell command through perl script

Posted on 2004-08-19
5
217 Views
Last Modified: 2013-12-26
how do i execute a shell command through a perl script?
0
Comment
Question by:hawky86
5 Comments
 
LVL 23

Accepted Solution

by:
brettmjohnson earned 168 total points
ID: 11846677
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 166 total points
ID: 11858060
You could also use qx`` or open or fork exec
0
 
LVL 44

Assisted Solution

by:Karl Heinz Kremer
Karl Heinz Kremer earned 166 total points
ID: 11921029
Do you just need to execute the command, or do you also need to either provide input to the shell command, or process the output of your shell command? If that's a requirement, you can use a pipe:

# to read from a program use something like this
open(MY_PIPE, "/bin/ls |");

while (<MY_PIPE>)
{
    # do something with the output read from the pipe
}
close(MY_PIPE);

# to write to a program use something like this:
open(MY_PIPE, "| sort");
print MY_PIPE "9999";
print MY_PIPE "8888";
print MY_PIPE "0000";
close(MY_PIPE);

# you need to provide your own error handling
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sumDigits challenge 9 150
while loop over for loop 7 103
how to use laptop or pad camera in vb.net windows application 2 71
Increment column based of a FK 8 22
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

772 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