Jump to content

C program seg faults when called in php script


Recommended Posts

I'm trying to call a program (hbplus) from the command line. 

When I run the program directly from the command line, it executes successfully.  When I run the program using the script below, I get a segmentation fault.  Any ideas why?

 

 

<?php

echo '<pre>';

$last_line = system('./hbplus', $retval);

// Printing additional info

echo '

</pre>

<hr />Last line of the output: ' . $last_line . '

<hr />Return value: ' . $retval;

?>

 

Link to comment
Share on other sites

I added to code to my script so that the console output was saved, and I got the following output:

 

-bash-4.0$ cat hboutput

./hbplus: /lib/libc.so.6: version `GLIBC_2.7' not found (required by ./hbplus)

 

When I run my program from the command line as shown, it executes succesfully.

-bash-4.0$ ./hbplus 1PEF.pdb

 

My php script:

 

<?php

echo '<pre>';

// Outputs all the result of shellcommand "ls", and returns

// the last output line into $last_line. Stores the return value

// of the shell command in $retval.

$last_line = system('./hbplus 1PEF.pdb &>hboutput', $retval);

 

// Printing additional info

echo '

</pre>

<hr />Last line of the output: ' . $last_line . '

<hr />Return value: ' . $retval;

?>

 

Link to comment
Share on other sites

  • 4 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.