Running Multiple Unix commands in qx


 
Thread Tools Search this Thread
Top Forums Programming Running Multiple Unix commands in qx
# 1  
Old 05-27-2010
Running Multiple Unix commands in qx

Hi All,

Is there anything wrong with below syntax?

Code:
qx {perldoc -v ModuleName.pm | grep -i Description }

BTW, this question is related to Perl.

Thanks.

Last edited by jal_capri; 05-27-2010 at 01:14 PM..
# 2  
Old 05-27-2010
Code:
$ perldoc -f qx
       qx/STRING/
       qw/STRING/
               Generalized quotes.  See "Regexp Quote-Like Operators" in per-
               lop.

# 3  
Old 05-28-2010
Quote:
Originally Posted by jal_capri
Hi All,

Is there anything wrong with below syntax?

Code:
qx {perldoc -v ModuleName.pm | grep -i Description }

BTW, this question is related to Perl.

Thanks.
nope.
but try:

Code:
print qx {perldoc -v ModuleName.pm | grep -i Description }

or more perlish:

Code:
open DOC, "perldoc -v ModuleName.pm|" or die;
while (<DOC>) {
  print if /Description/;
}

there's a million ways, what are you trying to achieve?
# 4  
Old 05-28-2010
Or, even more perlish:
Code:
open my $PD, '-|', 'perldoc -v ModuleName.pm' or die "$!";
print grep { /description/i } <$PD>;
close $PD;

Nevermind that this won't work, as the -v switch tells perldoc to look up a Perl variable, not a module. And even more Perlish would be if you'd used one of the Pod::* modules yourself to convert the documentation.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check status of long running multiple curl commands in shell script

I am working on script. it reads a file which contains multiple lines Ex; curl --write-out %{http_code} --silent --output /dev/null http://hostname:port/input=1 curl --write-out %{http_code} --silent --output /dev/null http://hostname:port/input=2 curl --write-out %{http_code} --silent ... (2 Replies)
Discussion started by: oraclermanpt
2 Replies

2. Shell Programming and Scripting

Perl script running multiple commands at once

Hi All, I have put a perl script together to go and collect some information from multiple nodes/endpoints. The script works absolutly fine however I want to make it quicker. You will see in the below that my script calls an expect script called ssh_run_cmd2.exp followed by the IP of... (7 Replies)
Discussion started by: mutley2202
7 Replies

3. Shell Programming and Scripting

Issue with running multiple commands withing su command

RHEL 6.2/Bash shell root user will be executing the below script. It switches to oracle user and expect to do the following things A. Source the environment variables for BATGPRD Database (the file used for sourcing is shown below after the script) B. Shutdown the DB from sqlplus -- The... (13 Replies)
Discussion started by: omega3
13 Replies

4. Shell Programming and Scripting

Running multiple commands stored as a semi-colon separated string

Hi, Is there a way in Korn Shell that I can run multiple commands stored as a semi-colon separated string, e.g., # vs="echo a; echo b;" # $vs a; echo b; I want to be able to store commands in a variable, then run all of it once and pipe the whole output to another program without using... (2 Replies)
Discussion started by: svhyd
2 Replies

5. Shell Programming and Scripting

Running unix commands in a perl script

Executing two unix commads via perl script one after another e.g: make clean bsub -i -q short make have tried using exec but the second command doesnt executes (1 Reply)
Discussion started by: rajroshan
1 Replies

6. Shell Programming and Scripting

Running multiple unix commands in a single script

Hi, I would like to write a script with include more than 6 unix commands. my script like below: echo " script started" ls -ld bdf | grep "rama" tail -10 log.txt ... .. ... now, i want to run above unix commands one by one. example: first the ls -ld command will be... (3 Replies)
Discussion started by: koti_rama
3 Replies

7. UNIX for Dummies Questions & Answers

running a simple script file with multiple commands

I'm trying to run a script file with multiple commands that I would normally type into the command line. The commands are: #!/bin/bash diff Test1.o0 /usr3/ronelso4/Desktop/verificationKPC/Test1.o0 > differences2 diff Test1a.o0 /usr3/ronelso4/Desktop/verificationKPC/Test1a.o0 >> differences2... (1 Reply)
Discussion started by: knelson
1 Replies

8. Shell Programming and Scripting

Running unix commands through perl

Hi all, In the directory '/temp/chris' the following files exist: chris.tar, chris.txt What i am trying to do is to assign the 'chris.tar' filename in an argument through perl, in order to do that i use the system command: $file=system("ls /temp/chris/*.tmp), but in the '$file' the exit... (2 Replies)
Discussion started by: chriss_58
2 Replies

9. Programming

Running UNIX Commands from C

Hi, -How can I get number of files, cpu usage (percentage), memory usage, disk usage, ...etc, using C program ... I can use unix command ( system(command) )but I want the value to be returned back to my C program to use it in my code? How can I do that? Thanks in advance ... (2 Replies)
Discussion started by: zainab
2 Replies

10. UNIX for Dummies Questions & Answers

Problem running plsql & unix commands in 1 script

Hi, I need help again. When I run this shell script, it only runs the unld_date.sql piece and exits. How can I structure this to run all the way to the end? When I don't have the unld_date.sql piece in here, everything runs fine from the date compare piece all the way to the end. Thanks in... (5 Replies)
Discussion started by: siog
5 Replies
Login or Register to Ask a Question