Checking Pipe Status Using Script At Comp.Unix.Shell FAQ

Checking Pipe Status Using Script At Comp.Unix.Shell FAQ

Post by absint » Thu, 10 Mar 2005 08:48:06



Hi Guys,

I've used the script at:
http://home.comcast.net/~j.p.h/cus-faq.html#M

It returns exit statuses in pipestatus_1 ... pipestatus_n. How do I go
about checking these one at a time to make sure they're 0 within a
function?

I'm trying to write a simple loop to check the pipestatuses but things
like:

j=1
echo $pipestatus_$j

and comparison tests based on $pipestatus_$j don't work. Any ideas?

 
 
 

Checking Pipe Status Using Script At Comp.Unix.Shell FAQ

Post by Icarus Sparr » Thu, 10 Mar 2005 10:25:53



> Hi Guys,

> I've used the script at:
> http://home.comcast.net/~j.p.h/cus-faq.html#M

> It returns exit statuses in pipestatus_1 ... pipestatus_n. How do I go
> about checking these one at a time to make sure they're 0 within a
> function?

> I'm trying to write a simple loop to check the pipestatuses but things
> like:

> j=1
> echo $pipestatus_$j

> and comparison tests based on $pipestatus_$j don't work. Any ideas?

The part of the script that reads
   j=1
   while eval "\${pipestatus_$j+:} false"; do
        eval "[ \$pipestatus_$j -eq 0 ]" || return 1
        j=$(($j+1))
   done

does this.

 
 
 

1. Run Script From Comp.Unix.Shell FAQ - Not Interpreting Commands

The code of run is as follows:
run()
{
    local j=1
    while eval "\${pipestatus_$j+:} false"; do
        unset pipestatus_$j
        j=$(($j+1))
    done

    j=1
    local com=
    local k=1
    local l=

    for a; do
         if [ "x$a" = 'x|' ]; then
           com="$com { $l "'3>&-
                       echo "pipestatus_'$j'=$?" >&3
                     } 4>&- |'
           j=$(($j+1))
           l=
         else
           l="$l \"\$$k\""
         fi
           k=$(($k+1))
    done

    com="$com $l"' 3>&- >&4 4>&-
          echo "pipestatus_'$j'=$?"'
          exec 4>&1
          eval "$(exec 3>&1; eval "$com")"
          exec 4>&-
          j=1

          while eval "\${pipestatus_$j+:} false"; do
            eval "[ \$pipestatus_$j -eq 0 ]" || return 1
            j=$(($j+1))
          done

          return 0

I'm writing a harness to poll Siebel's server manager...

I'm trying to pass run the following command:
run ${SRVRMGR} -g "${_siebelGateway}" -e "${_siebelEntName}" -s
"${_siebelServer}" -u "${_siebelUser}" -i "${SRVRMGRSCRIPT}" <
${_siebelPass} \| ${SED} -n -e "/${SEDDELSTRING}/d;s/
*${FLATFILEIFS}/${FLATFILEIFS}/g;s/${FLATFILEIFS} */${FLATFILEIFS}/g"
-e "/${SEDPRINTSTRING}/p"

Using run I get the cryptic output:

./srvrmgrHarness.ksh "list tasks for comp eim"
+ ./srvrmgrHarness.ksh list tasks for comp eim
./srvrmgrHarness.ksh[21]: srvrmgr3:  not found

However if I just use standard piping:
${SRVRMGR} -g "${_siebelGateway}" -e "${_siebelEntName}" -s
"${_siebelServer}" -u "${_siebelUser}" -i "${SRVRMGRSCRIPT}" <
${_siebelPass} | ${SED} -n -e "/${SEDDELSTRING}/d;s/
*${FLATFILEIFS}/${FLATFILEIFS}/g;s/${FLATFILEIFS} */${FLATFILEIFS}/g"
-e "/${SEDPRINTSTRING}/p"

It works fine. I've tried quoting each parameter, unquoting the whole
thing etc but I still get the same cryptic output from run. Can someone
help me?

2. Substring function/command in ksh

3. comp.unix.shell comp.sys.sun.admin comp.unix.questions

4. looking for latest *source* for xinetd with Linux configuration

5. comp.sys.hp comp.sys.sgi comp.sys.sun comp.unix.ultrix comp.unix.wizards

6. Linux LOGO idea...

7. exit status of the command in pipe from shell & named pipe

8. Adding fonts in RH 7.2

9. check status of a command in a shell script

10. comp.unix.shell,comp.unix.user-friendly

11. Why can't I post to comp.unix.shell, comp.unix.programmer?

12. comp.unix.questions comp.unix.misc comp.unix.sys5.r3

13. comp.unix.wizards comp.lang.c comp.sys.sun alt.unix.wizards alt.unix.wizards.free