Solved

shell command through perl script

Posted on 2004-08-19
5
224 Views
Last Modified: 2013-12-26
how do i execute a shell command through a perl script?
0
Comment
Question by:hawky86
[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
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Generic progress indicator 6 121
sameEnds challenge 3 196
maven archtype selection in eclipse 1 59
Fibonacci challenge 11 141
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: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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