Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

shell command through perl script

Posted on 2004-08-19
5
Medium Priority
?
238 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 672 total points
ID: 11846677
0
 
LVL 85

Assisted Solution

by:ozo
ozo earned 664 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 664 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

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

886 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