dd exit status (called trough popen)

dd exit status (called trough popen)

Post by Norbert Lakato » Sat, 16 Jun 2001 16:58:20



I need to execute a shell script trough pipe.
I call popen("./something.sh, SZ_READ);
cat something.sh
dd if=/dev/...

I need to catch dd's exit status.
TIA

 
 
 

dd exit status (called trough popen)

Post by Nithyanandha » Sat, 16 Jun 2001 18:36:47



> I need to execute a shell script trough pipe.
> I call popen("./something.sh, SZ_READ);
> cat something.sh
> dd if=/dev/...

echo $?  in ksh
echo $status in csh
echo $? in bourne sh

--Nithyanand.
  Siemens, Bangalore, India.

 
 
 

dd exit status (called trough popen)

Post by Christoph Hintermülle » Sat, 16 Jun 2001 18:45:19


Hi
I'm not sure
but woold the following help

dd if=/dev/... || exit $?

inside the shell script or schould it be also runable without your program
than i would put it like this

dd if=/dev/... && DD_sucess=$?
if [ "$DD_ABBORT_IMMIDEATLY" == "YES" ] && [ $DD_success -ne 0 ];then
   exit $DD_sucess
fi

and you will have to set the environment for your popen so that when
calling the script contains
the  `DD_ABBORT_IMMIDEATLY' variable to `YES' in order to make the
script return immediatly after dd
or any safe place in your script with the exitstatus of the first/last
failed dd

cu
Christoph

ps.; wouldn't it be much safer to fork a subprocess and call dd there
via exec function ???


> I need to execute a shell script trough pipe.
> I call popen("./something.sh, SZ_READ);
> cat something.sh
> dd if=/dev/...

> I need to catch dd's exit status.
> TIA

--
THESIS:     God is alive
PROOVE:     Who else would have scheduled the mankind and world first
             recommendation of research????
CONCLUSION: Scientists do what he wants, willing or not:)
 
 
 

dd exit status (called trough popen)

Post by Donald McLachl » Sat, 16 Jun 2001 21:04:33


Assuming you mean a bourne shell (if csh x=$status).  The following assumes
that you want to do more processing after the dd command, but saves the
exit status of dd so you can return it to popen().  

Quote:> I need to execute a shell script trough pipe.
> I call popen("./something.sh, SZ_READ);
> cat something.sh
> dd if=/dev/...

x=$?

...

exit $x

--

Communications Research Centre / RNS    Tel     (613) 998-2845
3701 Carling Ave.,                      Fax     (613) 998-9648
Ottawa, Ontario
K2H 8S2
Canada

 
 
 

dd exit status (called trough popen)

Post by Ralf Fasse » Sat, 16 Jun 2001 21:22:34



| I call popen("./something.sh, SZ_READ);
| cat something.sh
| dd if=/dev/...
| I need to catch dd's exit status.

This is what pclose() is for.

     A stream opened by popen should be closed by pclose, which waits
     for the associated process to terminate and returns the exit
     status of the command.

If `dd' is not the last command in the script, save the exit status in
the script and exit with that status later as suggested in a different
message in this thread.

R'

 
 
 

dd exit status (called trough popen)

Post by Norbert Lakato » Sat, 16 Jun 2001 23:44:57


On Fri, 15 Jun 2001 09:58:20 +0200, Norbert Lakatos


>I need to execute a shell script trough pipe.
>I call popen("./something.sh, SZ_READ);
>cat something.sh
>dd if=/dev/...

>I need to catch dd's exit status.
>TIA

Tnx to all of you!
At the end I used the return value from pclose() and it now works OK.
 
 
 

1. Help about popen() and exit status needed

                Hi, all!
How can I get _command_ exit status of the following construction:
        FILE* f1=popen(_command_,art);

        Thanks,
                        Oleg.

---
==============================================================================
     "InterWest"                                    Oleg Y. Pronin
  +7-0622-357-745

2. Can't log into FTP

3. checking for exit status of called program?

4. linux for A500, anybody can't help me???

5. getting exit status of called program via system

6. Modem Recommendations for IJPPP and HylaFax?

7. Returning exit status to calling script

8. Trouble with librarys on porting project.

9. exit status of a shell script called from system()

10. Exit status in trapped exit function

11. should xargs exit on non-zero program exit status?

12. Exit status, $?, and term status

13. How do I exit a process trough a script?