perl "system" cmd return values..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl "system" cmd return values..
# 1  
Old 11-24-2005
perl "system" cmd return values..

perl 5.6.1:

when i try a "system" command(with if loops for $?), i get this:

child exited with value 1


what is meant by this $? values and what does it meant if it returns 1?..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

What does "force devmap reload" as in "multipath -r" means for my system and stability of my system?

Cannot present unpresented disks back again. On a test server tried this as a solution "multipath -r" and it worked. Too worried to try it in production before I know all the information. Any info would be appreciated! Also some links to the documentation on this specific issue could help a... (1 Reply)
Discussion started by: jsteppe
1 Replies

2. Shell Programming and Scripting

PERL: DBI - Is it possible to get a "nicer" formatted return?

Hi, I am currently writing a perl module that will be passed queries from other scripts and use DBI to execute them on an Oracle Database. The problem I have is when it comes to the return. I am currently getting this from my code: FIELDA FIELDB FIELDC ... (6 Replies)
Discussion started by: chris01010
6 Replies

3. Shell Programming and Scripting

Perl: Printing null hash values as a " "?

I'm filling in a table of values for grades. I decided to go with reading into a hash from the files but I'm coming up with an error when printing a value that does not exist. I need to know if I can on-the-fly print a space (" ") or blank in place of the grade. Here's what the output should... (2 Replies)
Discussion started by: D2K
2 Replies

4. Shell Programming and Scripting

Perl open(CMD, "cmd |"); buffering problem..

Hello, There's a third-party application's command that shows the application's status like "tail -f verybusy.log". When use the command, the output comes every 1-sec. but when it goes in a script below the output comes every 8-sec...What is the problem and how can I fix it? open(CMD,... (2 Replies)
Discussion started by: Shawn, Lee
2 Replies

5. Shell Programming and Scripting

Problem using "system" command in perl

Hello!!! I'm trying to pass the output from bash command to perl variable in a perl script, and I used the "system" command to execute the bash statment and pass the result to perl string variable, in this perl script I used a variable $file that store data for using it as a regular expression.... (2 Replies)
Discussion started by: evolabo
2 Replies

6. Shell Programming and Scripting

Perl script with "chkconfig --list" cmd

Hi everybody; I try to code a script perl to list all services that are active "ON" with a chkconfig -- list the problem is that code list all services which are active or not. #!/usr/bin/perl use strict; use warnings; open(FILE,"-|") || exec "chkconfig --list |grep ON";... (2 Replies)
Discussion started by: bassma
2 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. Shell Programming and Scripting

Perl - How to print a "carriage return" to an output file?

Let's say I want to write a program that run these 4 UNIX commands and redirect output to a file. #!/usr/local/bin/perl use strict; `cd \$HOME > output.txt`; `cut -f1 inputfile.txt >> output.txt`; `hostname >> output.txt`; `ifconfig >> output.txt`; I want to print a "carriage return"... (5 Replies)
Discussion started by: teiji
5 Replies

9. Shell Programming and Scripting

Need help on use of "cmd" command in net::Telnet module in PERL

in "cmd" command i want to copy the ouput of the command excuted to a particular file in a directory. How to do this..?? Ex : $telnet->cmd(String => 'allip:acl=a1;',Prompt => '/</'); i want to copy o/p of the command "allip:acl=a1;" in a log file in a particular directory. Plz suggest.. (1 Reply)
Discussion started by: sudhakaryadav
1 Replies

10. Shell Programming and Scripting

how to change "set" values in perl, windows...

i am using perl in win2000advanced server... --------------------------- perl -version: --------------------------- This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2001, Larry Wall Binary build 638 provided by... (1 Reply)
Discussion started by: sekar sundaram
1 Replies
Login or Register to Ask a Question
Paranoid::Process(3pm)					User Contributed Perl Documentation				    Paranoid::Process(3pm)

NAME
Paranoid::Process - Process Management Functions VERSION
$Id: Process.pm,v 1.01 2010/05/10 04:55:07 acorliss Exp $ SYNOPSIS
use Paranoid::Process; $rv = daemonize(); MAXCHILDREN = 100; $SIG{CHLD} = &sigchld; $count = childrenCount(); installChldHandler($sub); $rv = pfork(); $uid = ptranslateUser("foo"); $gid = ptranslateGroup("foo"); $rv = switchUser($user, $group); $rv = pcapture($cmd, $crv, $out); DESCRIPTION
This module provides a few functions meant to make life easier when managing processes. The following export targets are provided: all All functions within this module pfork All child management functions Only the functions switchUser and daemonize are currently exported by default. SUBROUTINES
/METHODS MAXCHILDREN Setting this lvalue subroutine sets a limit to how many children will be forked at a time by pfork. The default is zero, which allows unlimited children. Once the limit is met pfork becomes a blocking call until a child exits so the new one can be spawned. childrenCount $count = childrenCount(); This function returns the current number of children spawned by pfork. installChldHandler installChldHandler($sub); This function takes a reference to a subroutine. If used the subroutine will be called every time a child exits. That subroutine will be called with the child's PID and exit value as arguments. sigchld $SIG{CHLD} = &sigchld; This function decrements the child counter necessary for pfork's operation, as well as calling the user's signal handler with each child's PID and exit value. daemonize $rv = daemonize(); This function forks a child who reopens all STD* filehandles on /dev/null and starts a new process group. The parent exits cleanly. If the fork fails for any reason it returns a false value. The child will also change its directory to /. pfork $rv = pfork(); This function should be used in lieu of Perl's fork if you want to take advantage of a blocking fork call that respects the MAXCHILDREN limit. Use of this function, however, also assumes the use of sigchld as the signal handler for SIGCHLD. ptranslateUser $uid = ptranslateUser("foo"); This function takes a username and returns the corresponding UID as returned by getpwent. If no match is found it returns undef. ptranslateGroup $gid = ptranslateGroup("foo"); This function takes a group name and returns the corresponding GID as returned by getgrent. If no match is found it returns undef. switchUser $rv = switchUser($user, $group); This function can be fed one or two arguments, both either named user or group, or UID or GID. Both user and group arguments are optional as long as the other is called. In other words, you can pass undef for one of the arguments, but not for both. If you're only switching the user you can pass only the user argument. pcapture $rv = pcapture($cmd, $crv, $out); This function executes the passed shell command and returns one of the following three values: RV Description ======================================================= -1 Command failed to execute or died with signal 0 Command executed but exited with a non-0 RV 1 Command executed and exited with a 0 RV The actual return value is populated in the passed scalar reference, while all STDERR/STDOUT output is stored in the last scalar reference. Any errors executing the command will have the error string stored in Paranoid::ERROR. If the command exited cleanly it will automatically be bit shifted eight bits. NOTE: Unlike many other functions in this suite it is up to you to detaint the command passed to this function yourself. There's simply no way for me to know ahead of time what kind of convoluted arguments you might be handing this call before system is called. Failing to detaint that argument will cause your script to exit under taint mode. DEPENDENCIES
o Paranoid o Paranoid::Debug o POSIX EXAMPLES
pfork This following example caps the number of children processes to three at a time: $SIG{CHLD} = &sigchld; MAXCHILDREN = 3; for (1 .. 5) { # Only the children execute the following block unless ($pid = pfork()) { # .... exit 0; } } You can also install a child-exit routine to be called by sigchld. For instance, to track the children's history in the parent: sub recordChild ($$) { my ($cpid, $cexit) = @_; push(@chistory, [$cpid, $cexit]); } installChldHandler(&recordChild); for (1 .. 5) { unless ($pid = pfork()) { # .... exit $rv; } } # Prints the child process history foreach (@chistory) { print "PID: $$_[0] EXIT: $$_[1] " }; BUGS AND LIMITATIONS
There's a bug in an current versions of Perl where ptranslateGroup can return negative numbers instead the actual GID. This is due to the platform supporting unsigned integers for the GID, but Perl was casting it as a signed integer. A patch has been submitted to blead-perl. On Solaris pcapture doesn't return a -1 for non-existant commands, but a 0. On Linux this appears to work as intended. AUTHOR
Arthur Corliss (corliss@digitalmages.com) LICENSE AND COPYRIGHT
This software is licensed under the same terms as Perl, itself. Please see http://dev.perl.org/licenses/ for more information. (c) 2005, Arthur Corliss (corliss@digitalmages.com) perl v5.14.2 2010-05-10 Paranoid::Process(3pm)