Prlblems with Backtick Commands 
Author Message
 Prlblems with Backtick Commands


I'm working on HP-UX 10.20 (Perl version 5.004_01) and Compaq/Digital Unix 4.0D
(Perl version 5.004_04 built for alpha-dec_osf).
I wrote some perl scripts which must be able to run under both platforms.
Somtimes I need the MAC address of one of the LAN cards. On HP
I use the command "/usr/sbin/lanscan" and on Compaq "netstat -I tu0",
performed as backtick commands.
The script works on both platforms without problems, see below.
Now I have added a signal handler routine for SIGCHLD. After
this modification the behaviour of the script is different on both
platforms. On HP-UX the script works correct, but on Compaq the backtick
commands works somtimes correct and sometimes not, i.e. the

Then I have 'simplified the script' performing only the backtick command
in a loop - with the same result. If the signal handler routine is not
installed the script works correct on both platforms; if the routine
is installed the script works sometimes incorrect on Compaq.

Has someone an idea about the reason for this behaviour?
How can I solve this problem?

Best regards,


   my ($platform, $macAddr);

   $platform = `uname`;

   $SIG{CHLD} = \&signalHandler;

   if ($platform eq "OSF1") {

         $macAddr =~ ... # grep MAC from Output
      else {
         die "No return of command <netstat -I tu0>"
   elsif ($platform eq "HP-UX") {

         $macAddr =~ ... # grep MAC from Output
      else {
         die "No return of command </usr/sbin/lanscan>"
   else {
      # error
      die "Platform not supported";

   print STDOUT "MAC Address found is $macAddr";


sub signalHandler

   print STDOUT "\n\nINFO ===> Caught a Signal: SIG$signalName --\n";



Frank Ilchmann

Sat, 27 Oct 2001 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. pipe problem in backticks/system command

2. Restrictions on shell commands in backticks?

3. Perl command line and backticks

4. backticks/system command

5. Perl (backticks) behaviour with DB2 commands on various Unixes

6. Passing Input to a Command in Backticks

7. Return value from backtick command needs to be 32-bit signed

8. HowTo: Run a command in backticks as root?

9. Executing commands via backticks

10. END block and backtick command

11. How to redirect standard output of a backtick command

12. Backtick Commands in Server Apps


Powered by phpBB® Forum Software