Cannot execute Unix command in a simple perl script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cannot execute Unix command in a simple perl script
# 8  
Old 09-23-2011
I've already answered that, twice, and did so before suggesting any other solutions. I have no idea if my suggestion worked or not, and having no way to test it here myself, I must wait for you to do as I asked to find out.

To spell it out keystroke by keystroke:
$FREE = `vgdisplay $A | grep -i 'Free PE' | awk '{print \$NF}'`;

I should note you're running sh 4 separate times, awk twice, and perl once; it's a bit of a stretch to call your script 'perl'. You're also running 14 processes when all you needed was 2. If you really want to do it in perl, you should be processing all the output in perl.

Last edited by Corona688; 09-23-2011 at 06:23 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies

2. Linux

How to execute a simple select script using a shell script?

Hi team, I have two select statements and need to run them using SYSDBA user select * from temp_temp_seg_usage; select segment_name, tablespace_name, bytes/ (1024*1024) UsedMb from dba_segments where segment_name='TEMP_TEMP_SEG_USAGE'; Need to run this using a shell script say named... (1 Reply)
Discussion started by: pamsy78
1 Replies

3. Shell Programming and Scripting

Using UNIX command in perl script.

I wish to know if there is any limitation in using unix commands in perl script or it is just we should avoid using them in our perl script. For e.g Below is the command to get the recent file in a dir.: $lcsvFile = `cd "$l_inputfilepath";ls -1t *.CSV|tail -1` Is there any harm in coding... (1 Reply)
Discussion started by: Devesh5683
1 Replies

4. UNIX for Dummies Questions & Answers

Execute a command in different directory through Unix Script

Hi Gurus, I have the below requirement, Execute an unix script which will pick the latest file from the archive directory and do a grep (on multiple patterns) on that file. processingDir="/usr/apps/irdc/informatica/spsf_sales/TgtFiles/ARCHIVE" filename = 'ls Check* | sort -n -k 2 |... (6 Replies)
Discussion started by: diva_thilak
6 Replies

5. Shell Programming and Scripting

execute ssh command via perl

Hi I have a perl command that doesn't seem to be working correctly. It appears to be fine but even when i try and run it manually same thing. Can someone take a look at this and tell me what they think the problem could be? Here is the perl Line: system ("echo 'ssh -t -t $user\@$_ \"cd... (3 Replies)
Discussion started by: vpundit
3 Replies

6. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

7. Shell Programming and Scripting

how to execute ksh simple shell script without creating .sh file

please help me to execute a simple shell script like for i in `ls echo $i done . i dont want to create a new sh file to execute it. Can i just type and execute it ? because I always this kind of simple for loops . Please help . Thanks (7 Replies)
Discussion started by: Sooraj_Linux
7 Replies

8. Shell Programming and Scripting

perl/unix: script in command line works but not in perl

so in unix this command works works and shows me a list of directories find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt but when i try running a perl script to run this command my $query = 'find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt';... (2 Replies)
Discussion started by: kpddong
2 Replies

9. Shell Programming and Scripting

Execute in unix not in PERL

Hi All, This below command is working fine with unix box. However i could not able to run it in PERL. kidly suggest??? perl -ne '{push @x, $_}END{pop(@x); print @x}' create2.txt (15 Replies)
Discussion started by: adaleru
15 Replies

10. Shell Programming and Scripting

Net::SSH::Perl->Execute any unix command & display the output in a proper form

Net::SSH::Perl ...... how to print the output in a proper format my $cmd = "ls -l"; my $ssh = Net::SSH::Perl->new($host); $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd("$cmd"); print $stdout; the script works fine, but i am unable to see the output... (2 Replies)
Discussion started by: gsprasanna
2 Replies
Login or Register to Ask a Question
Plack::App::CGIBin(3pm) 				User Contributed Perl Documentation				   Plack::App::CGIBin(3pm)

Plack::App::CGIBin - cgi-bin replacement for Plack servers SYNOPSIS
use Plack::App::CGIBin; use Plack::Builder; my $app = Plack::App::CGIBin->new(root => "/path/to/cgi-bin")->to_app; builder { mount "/cgi-bin" => $app; }; # Or from the command line plackup -MPlack::App::CGIBin -e 'Plack::App::CGIBin->new(root => "/path/to/cgi-bin")->to_app' DESCRIPTION
Plack::App::CGIBin allows you to load CGI scripts from a directory and convert them into a PSGI application. This would give you the extreme easiness when you have bunch of old CGI scripts that is loaded using cgi-bin of Apache web server. HOW IT WORKS
This application checks if a given file path is a perl script and if so, uses CGI::Compile to compile a CGI script into a sub (like ModPerl::Registry) and then run it as a persistent application using CGI::Emulate::PSGI. If the given file is not a perl script, it executes the script just like a normal CGI script with fork & exec. This is like a normal web server mode and no performance benefit is achieved. The default mechanism to determine if a given file is a Perl script is as follows: o Check if the filename ends with ".pl". If yes, it is a Perl script. o Open the file and see if the shebang (first line of the file) contains the word "perl" (like "#!/usr/bin/perl"). If yes, it is a Perl script. You can customize this behavior by passing "exec_cb" callback, which takes a file path to its first argument. For example, if your perl-based CGI script uses lots of global variables and such and are not ready to run on a persistent environment, you can do: my $app = Plack::App::CGIBin->new( root => "/path/to/cgi-bin", exec_cb => sub { 1 }, )->to_app; to always force the execute option for any files. AUTHOR
Tatsuhiko Miyagawa SEE ALSO
Plack::App::File CGI::Emulate::PSGI CGI::Compile Plack::App::WrapCGI See also Plack::App::WrapCGI if you compile one CGI script into a PSGI application without serving CGI scripts from a directory, to remove overhead of filesystem lookups, etc. perl v5.14.2 2011-11-02 Plack::App::CGIBin(3pm)