Sponsored Content
Top Forums Shell Programming and Scripting Return code is "0" though the command fails. Post 302278529 by pbekal on Tuesday 20th of January 2009 01:02:52 PM
Old 01-20-2009
Quote:
Originally Posted by cfajohnson

That will fail if any filenames contain spaces.
Your suggestion works.
Thank You.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

#!/bin/sh script fails at StringA | tr "[x]" "[y]"

I need to take a string (stringA) check it for spaces and replace any spaces found with an equal (=) sign. This is not working. There are spaces between each component: $StringA | tr "" "" The error returned is: test: Specify a parameter with this command Can you help? (3 Replies)
Discussion started by: by_tg
3 Replies

2. UNIX for Dummies Questions & Answers

return code capturing for all commands connected by "|" ...

Hi, While I am using "|" to join multiple commands, I am not getting the return code when there is error in one of the commnads. Eg: b=`find /path/a*.out | xargs basename` if ; then echo "Error" fi if there is error while finding the file or getting the basename, the $? is... (6 Replies)
Discussion started by: new_learner
6 Replies

3. UNIX for Dummies Questions & Answers

Command 'rm -f -r "0yfOYy-0008Nq-2j-32233-K"' failed with return code 1 and error mes

I would like to know what means this error and how to fix it Command 'rm -f -r "0yfOYy-0008Nq-2j-32233-K"' failed with return code 1 and error message Thank you (3 Replies)
Discussion started by: linuxbee
3 Replies

4. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

5. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

6. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 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. UNIX for Dummies Questions & Answers

Unix "look" Command "File too large" Error Message

I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this: $ look "string" "/home/patrick/filename.txt" However, this gives me the following message: "look: /home/patrick/filename.txt: File too large" So, I have two... (14 Replies)
Discussion started by: shishong
14 Replies

9. UNIX for Dummies Questions & Answers

Crontab -e command return "413"

I was trying to edit the crontab file for root. I had saved off the existing file for later recovery. When I typed crontab -e to edit, the system returned "413" and the cursor stopped blinking. Ctrl+c stopped that. I typed, in bash, "EDITOR=vi" (Enter). Then, "export EDITOR" (Enter). Then,... (2 Replies)
Discussion started by: roadmanjim
2 Replies

10. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies
SyncExec(3pm)						User Contributed Perl Documentation					     SyncExec(3pm)

NAME
Proc::SyncExec - Spawn processes but report exec() errors SYNOPSIS
# Normal-looking piped opens which properly report exec() errors in $!: sync_open WRITER_FH, "|command -with args" or die $!; sync_open READER_FH, "command -with args|" or die $!; # Synchronized fork/exec which reports exec errors in $!: $pid = sync_exec $command, @arg; $pid = sync_exec $code_ref, $cmd, @arg; # run code after fork in kid # fork() which retries if it fails, then croaks() if it still fails. $pid = fork_retry; $pid = fork_retry 100; # retry 100 times rather than 5 $pid = fork_retry 100, 2; # sleep 2 rather than 5 seconds between # A couple of interfaces similar to sync_open() but which let you # avoid the shell: $pid = sync_fhpopen_noshell READERFH, 'r', @command; $pid = sync_fhpopen_noshell WRITERFH, 'w', @command; $fh = sync_popen_noshell 'r', @command_which_outputs; $fh = sync_popen_noshell 'w', @command_which_inputs; ($fh, $pid) = sync_popen_noshell 'r', @command_which_outputs; ($fh, $pid)= sync_popen_noshell 'w', @command_which_inputs; DESCRIPTION
This module contains functions for synchronized process spawning with full error return. If the child's exec() call fails the reason for the failure is reported back to the parent. These functions will croak() if they encounter an unexpected system error, such as a pipe() failure or a repeated fork() failure. Nothing is exported by default. fork_retry [max-retries [sleep-between]] This function runs fork() until it succeeds or until max-retries (default 5) attempts have been made, sleeping sleep-between seconds (default 5) between attempts. If the last fork() fails fork_retry croak()s. sync_exec [code] command... This function is similar to a fork()/exec() sequence but with a few twists. sync_exec does not return until after the fork()ed child has already performed its exec(). The synchronization this provides is useful in some unusual circumstances. Normally the pid of the child process is returned. However, if the child fails its exec() sync_exec returns undef and sets $! to the reason for the child's exec() failure. Since the @cmd array is passed directly to Perl's exec() Perl might choose to invoke the command via the shell if @cmd contains only one element and it looks like it needs a shell to interpret it. If this happens the return value of sync_exec only indicates whether the exec() of the shell worked. The optional initial code argument must be a code reference. If it is present it is run in the child just before exec() is called. You can use this to set up redirections or whatever. If code returns false no exec is performed, instead a failure is returned using the current $! value (or EINTR if $! is 0). If the fork() fails or if there is some other unexpected system error sync_exec croak()s rather than returning. sync_fhpopen_noshell fh type cmd [arg]... This is a popen() but it never invokes the shell and it uses sync_exec() under the covers. See "sync_exec". The type is either 'r' to read from the process or 'w' to write to it. The return value is the pid of the forked process. sync_popen_noshell type cmd arg... This is like sync_fhpopen_noshell, but you don't have to supply the filehandle. If called in an array context the return value is a list consisting of the filehandle and the PID of the child. In a scalar context only the filehandle is returned. sync_open fh [open-spec] This is like a Perl open() except that if a pipe is involved and the implied exec() fails sync_open() fails with $! set appropriately. See "sync_exec". Like sync_exec, sync_open croak()s if there is an unexpected system error (such as a failed pipe()). Also like sync_exec, if you use a command which Perl needs to use the shell to interpret you'll only know if the exec of the shell worked. Use sync_fhpopen_noshell or sync_exec to be sure that this doesn't happen. AUTHOR
Roderick Schertler <roderick@argon.org> SEE ALSO
perl(1). perl v5.8.8 2005-02-04 SyncExec(3pm)
All times are GMT -4. The time now is 08:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy