How to check for an error if executing a shell command e.g. withsystem('commandhere')?

K

kazaam

Hi,
I'm writing a little script to install some drivers but I wanna react in this script if any step fails. So e.g. I'm doing this:
system('dpkg -i xorg-driver-fglrx fglrx-kernel-source')
How can I check if this was succesful or if there was any error?
 
S

Sebastian Hungerecker

kazaam said:
system('dpkg -i xorg-driver-fglrx fglrx-kernel-source')
How can I check if this was succesful or if there was any error?

system returns true or false depending on whether or not the command exited
successfully. You can also look at the exit status via the global var $?
HTH
 
S

Stefano Crocco

Alle venerd=EC 24 agosto 2007, kazaam ha scritto:
Hi,
I'm writing a little script to install some drivers but I wanna react in
this script if any step fails. So e.g. I'm doing this: system('dpkg -i
xorg-driver-fglrx fglrx-kernel-source')
How can I check if this was succesful or if there was any error?

I think you should check the return value of system. It will return true if=
=20
the command was run successfully and false otherwise.

Stefano
 
K

kazaam

lol thanks this really works :D

Alle venerdì 24 agosto 2007, kazaam ha scritto:

I think you should check the return value of system. It will return true if
the command was run successfully and false otherwise.

Stefano
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,264
Messages
2,571,317
Members
48,002
Latest member
DoloresMan

Latest Threads

Top