Search the web
Sign In
New User? Sign Up
perl-beginner · Perl Beginners Mailing List
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
#ARGV and parameters with embedded spaces.   Message List  
Reply | Forward Message #26663 of 26731 |
RE: [PBML] Using System Command in Perl

I TRIED IT THIS WAY.. INCLUDING WITH THE BACK LASHES. But I still get
nothing.. And I show nothing ran in task manager..



open my $command, "e:\BMC Software\CONTROL-M
Server\Ctm_server\Exe\CTMORDER.exe -SCHEDTAB EM-QW-D-REPORT-LOGS -JOBNAME
EM-QW-D-AS-AAL-EMAIL -ODATE ODAT -FORCE Y";



while (my $line = <$command>) {



print $line; # you could do other stuff with this...

}



close $command;



exit;



From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com]
On Behalf Of Jeff Soules
Sent: Wednesday, June 24, 2009 9:58 AM
To: perl-beginner@yahoogroups.com
Subject: Re: [PBML] Using System Command in Perl








Maybe the backtick operator ` `? (Backtick on my keyboard is the
tilde key ~ without shift, but it might be different on your
keyboard).

So in place of:

> system 'CTMORDER -SCHEDTAB EM-$ENV-REPORT-LOGS -JOBNAME
> EM-$ENV-$Client_Key-AAL-EMAIL -ODATE ODAT -FORCE Y';

You'd do

my $result = `CTMORDER -SCHEDTAB EM-$ENV-REPORT-LOGS -JOBNAME
EM-$ENV-$Client_Key-AAL-EMAIL -ODATE ODAT -FORCE Y`;

and then look in $result for whatever the other utility would normally
print on the screen.

$? is supposed to be set the same way for system() as for the backtick
operator, but maybe your other Windows program isn't returning a
status properly or something?

On Tue, Jun 23, 2009 at 9:33 PM, Kevin Patterson<kpatters@...
<mailto:kpatters%40berkeley.edu> > wrote:
>
>
>
>
> Hi,
>
> I am writing a perl program to call/ execute another windows program
>
> Using the system command.
>
> I am trying to get/print the results to see if the command worked.
>
> Is there a way to capture the output of what the program ran??
>
> I tried using system ' ' and system(). I get the same results.. nothing..
>
> Here is my code so far.
>
> #!/usr/bin/perl
>
> # use strict;
>
> # use warnings;
>
> @client = qw(EM AS);
>
> #@client = qw(EM HR KR AS BF DB);
>
> my $eNV = "QW-D";
>
> my $T = '"';
>
> foreach $Client_Key (@client)
>
> {
>
> system 'CTMORDER -SCHEDTAB EM-$ENV-REPORT-LOGS -JOBNAME
> EM-$ENV-$Client_Key-AAL-EMAIL -ODATE ODAT -FORCE Y';
>
> print "Status: $? $!\n";
>
> }
>
> [Non-text portions of this message have been removed]
>
>





[Non-text portions of this message have been removed]




Wed Jun 24, 2009 5:09 pm

cside30
Offline Offline
Send Email Send Email

Forward
Message #26663 of 26731 |
Expand Messages Author Sort by Date

Hi, My script to add a new user is below, written on solaris 10. Running it using either of these two ways (one with double quotes around the second parameter...
Regina Miller
rmiller571957
Offline Send Email
Jun 17, 2009
3:29 pm

... Hi! First of all, you shouldn't use $ARGV[0] , $ARGV[1], etc. directly. Do: {{{ my ($first_name, $last_name, $address) = @ARGV; }}} Which is a much more...
Shlomi Fish
shlomif2
Offline Send Email
Jun 17, 2009
3:49 pm

Thanks very much for the advice on not using $ARGV's directly. I will change my code to match. But I'm not sure how your example of system("echo"...) applies...
rmiller571957
Offline Send Email
Jun 17, 2009
4:38 pm

... It's not $ARGV - it's @ARGV. @ARGV is the entire array. $ARGV[$index] is an individual element of it. There's also $ARGV in Perl which is a different ...
Shlomi Fish
shlomif2
Offline Send Email
Jun 17, 2009
4:54 pm

Hi Regina, The problem is caused by the eval shell statement: eval "exec ctperl -S $0 $*" When the shell runs your shell script, the quotation marks have...
Chris Seip
ssvfmnx
Offline Send Email
Jun 17, 2009
5:25 pm

This worked! Thank you so much! But now I'm having trouble passing my embedded-space-parameter on to the useradd routine. Here is my current code. The...
rmiller571957
Offline Send Email
Jun 17, 2009
6:50 pm

... rmiller571957> But how can I pass it on to the useradd command as one parameter? As Shlomi Fish already showed you before... using a multi-arg system...
merlyn@...
merlynstoneh...
Offline Send Email
Jun 17, 2009
6:56 pm

Thank you! And Shlomi, I'm sorry I didn't understand your response. I played with it for about 10 minutes, but just didn't see how it fit in with my...
rmiller571957
Offline Send Email
Jun 17, 2009
7:02 pm

Hello.. I am writing a perl program in windows.. Here is my problem. I have a file containing data such as: Apples Oranges Pears Bananas Plums Apples Oranges ...
Kevin Patterson
cside30
Offline Send Email
Jun 17, 2009
7:11 pm

... Kevin> I write a program to read this file and create a summary report showing Kevin> How many apples: Kevin> How many oranges Kevin> How many Pears ...
merlyn@...
merlynstoneh...
Offline Send Email
Jun 17, 2009
7:15 pm

What is the exact format of the file? What have you tried so far? Nobody is going to write the script for you. The group is here to help you figure things out...
Scot Robnett
web4success2...
Offline Send Email
Jun 17, 2009
7:22 pm

Sorry... Here is what I wrote: #!/usr/bin/perl #use warnings; #use diagnostics; my $count = 0; my $key_count = 0; $Input_File="crapdata1.txt"; open(INP,...
Kevin Patterson
cside30
Offline Send Email
Jun 17, 2009
8:18 pm

I fixed it. #!/usr/bin/perl #use warnings; #use diagnostics; my $count = 0; @client = qw(apples oranges pears kiwi); $Input_File="crapdata1.txt"; open(INP,...
Kevin Patterson
cside30
Offline Send Email
Jun 17, 2009
8:42 pm

Hi, I am writing a perl program to call/ execute another windows program Using the system command. I am trying to get/print the results to see if the command...
Kevin Patterson
cside30
Offline Send Email
Jun 24, 2009
1:35 am

... Try opening the the command with a piped file handle, like so... the below example will execute a given command and print the output to the screen (you...
Dan Stephenson
ispyhumanfly@...
Send Email
Jun 24, 2009
1:55 am

Maybe the backtick operator ` `? (Backtick on my keyboard is the tilde key ~ without shift, but it might be different on your keyboard). ... You'd do my...
Jeff Soules
soules@...
Send Email
Jun 24, 2009
4:58 pm

I TRIED IT THIS WAY.. INCLUDING WITH THE BACK LASHES. But I still get nothing.. And I show nothing ran in task manager.. open my $command, "e:\BMC...
Kevin Patterson
cside30
Offline Send Email
Jun 24, 2009
5:12 pm

When executing this command, don't forget to redirect the STDERR to STDIO, else you won't be able to figure out the reason why command has failed, so i will...
vishal thakur
v_thakur123
Offline Send Email
Jun 25, 2009
7:04 am

... In that case, make sure you use String-ShellQuote: http://search.cpan.org/dist/String-ShellQuote/ Alternatively use open '-|', @list which is only...
Shlomi Fish
shlomif2
Offline Send Email
Jun 25, 2009
9:40 am

You've had prior experience with other programming languages, right? Using substr() this way is a very C or Java way of doing things. Read up on hashes...
Jeff Soules
soules@...
Send Email
Jun 17, 2009
8:46 pm

Thanks. I am reading on hashes now and practicing on how to use them. I have not taken any perl classes.. I just started reading the books. From:...
Kevin Patterson
cside30
Offline Send Email
Jun 17, 2009
8:50 pm

... If you're learning from books, I cannot recommend _Learning_Perl_ highly enough. It's got a very intelligent presentation order, tons of useful example...
Jeff Soules
soules@...
Send Email
Jun 17, 2009
8:54 pm

Thanks. I have it on order and reading it online now.. From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com] On Behalf Of Jeff Soules ...
Kevin Patterson
cside30
Offline Send Email
Jun 17, 2009
8:59 pm

Ok. Im stuck again. I need to sort this input file below before my code.. Cant someone help me with this?? ... <mailto:perl-beginner%40yahoogroups.com> ...
Kevin Patterson
cside30
Offline Send Email
Jun 17, 2009
10:10 pm

In a Unix environment, the easiest way to sort the file would be to use the sort utility on the file. But you said you're running in Windows. So, since your...
Jeff Soules
soules@...
Send Email
Jun 18, 2009
12:22 pm

Hope this helps Output: Apples count is: 3 Oranges count is: 3 Pears count is: 3 Src: #!/usr/bin/perl use strict; use warnings; my $count = 0; my...
Robert Lee Binkley
leebinkley
Offline Send Email
Jun 19, 2009
4:40 am

... Kevin> I have it on order and reading it online now.. I hope by "reading it online" you mean you have a safari.oreilly.com account (or access to it through...
merlyn@...
merlynstoneh...
Offline Send Email
Jun 17, 2009
11:03 pm

Hi, try to have a hash containing the frequencies. IMHO it is not a Perl issue. Get some info on algorithms Gabaux ... Hello.. I am writing a perl program in...
Urban Gabor
gabauxhu
Offline Send Email
Jun 17, 2009
8:15 pm

# cat add_smbuser #!/sbin/sh # This script must be invoked each time a new user # is added to the UB-Domain (SAM), so he will find his home and # a backup...
Robert Lee Binkley
leebinkley
Offline Send Email
Jun 17, 2009
5:52 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help