URL: https://www.opennet.me/cgi-bin/openforum/vsluhboard.cgi
Форум: vsluhforumID9
Нить номер: 4089
[ Назад ]

Исходное сообщение
"Получить код возврата от внешней программы"

Отправлено astenax , 23-Мрт-05 07:53 
День добрый!

Каким образом можно получить код возврата при выполнении внешнего приложения? Т.е. я вызываю программу из скрипта на perl, но мне нужен не вывод это программы (@result=`date`), а именно тот код возврата который устанавливает внешенее приложени при выходе. Т.е. то же самое, что в shell дает $?.


Содержание

Сообщения в этом обсуждении
"Получить код возврата от внешней программы"
Отправлено allez , 23-Мрт-05 08:17 
Смотрим "perldoc perlfunc", функция system():

>               Because `system' and backticks block `SIGINT' and
>               `SIGQUIT', killing the program they're running
>               doesn't actually interrupt your program.
>
>                   @args = ("command", "arg1", "arg2");
>                   system(@args) == 0
>                        or die "system @args failed: $?"
>
>               You can check all the failure possibilities by
>               inspecting `$?' like this:
>
>                   $exit_value  = $? >> 8;
>                   $signal_num  = $? & 127;
>                   $dumped_core = $? & 128;
>
>               When the arguments get executed via the system
>               shell, results and return codes will be subject to
>               its quirks and capabilities.  See the section on
>               "`STRING`" in the perlop manpage and the exec
>               entry elsewhere in this document for details.


"Получить код возврата от внешней программы"
Отправлено astenax , 23-Мрт-05 08:23 
>Смотрим "perldoc perlfunc", функция system():
>
>>               Because `system' and backticks block `SIGINT' and
>>               `SIGQUIT', killing the program they're running
>>               doesn't actually interrupt your program.
>>
>>                   @args = ("command", "arg1", "arg2");
>>                   system(@args) == 0
>>                        or die "system @args failed: $?"
>>
>>               You can check all the failure possibilities by
>>               inspecting `$?' like this:
>>
>>                   $exit_value  = $? >> 8;
>>                   $signal_num  = $? & 127;
>>                   $dumped_core = $? & 128;
>>
>>               When the arguments get executed via the system
>>               shell, results and return codes will be subject to
>>               its quirks and capabilities.  See the section on
>>               "`STRING`" in the perlop manpage and the exec
>>               entry elsewhere in this document for details.


Тьфу ты, тоже только увидел :(