LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-16-2017, 02:38 PM   #1
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 490
Blog Entries: 4

Rep: Reputation: 238Reputation: 238Reputation: 238
php ajax can't call binary in cgi-bin


This thread may belong to Linux-Server since it appears to be a server issue, but i think there must be someway i can change my php script to solve.

My linux / ngx hosting service recently 'upgraded' their hardware and software. Since they have done so, all php scripts trying to invoke a native linux binary in cgi-bin can no longer open or execute the binary. Here's the php code snippet:
Code:
$subprog = "sudcgif";
$url = "http://cyberjerry.com/cgi-bin/".$subprog;
$data = "?req=".$p_req."&all81=".$p_arg0;
$params = array('http' => array(
                'method' => 'post',
                'content' => $data
               ));
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
 print("Fatal error in ".$url.", ".$php_errormsg);
 exit(1);
 }
This has been working flawlessly for several years, now the fopen fails. I've changed nothing in the php script or binary, so the problem has to be the hosting service's recent upgrade.

When i asked what they've recently changed, their tech support said:
"were using a new php parser calle 'lsapi' and new hardware / cloud infrastructure."

What i'm specifically asking is whether something in my php code is obsolete and may have to change.

Any ideas?

Last edited by dogpatch; 08-16-2017 at 02:46 PM. Reason: quote tech support
 
Old 08-16-2017, 02:43 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
You should check file error_log. Or simply read the message your program prints.
 
1 members found this post helpful.
Old 08-16-2017, 02:52 PM   #3
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 490

Original Poster
Blog Entries: 4

Rep: Reputation: 238Reputation: 238Reputation: 238
I see nothing in the error log. My php code reports "Fatal error..." as seen in the above code snippet

This affects all of my several ajax calls to a binary executable, so i think the problem must be in the above code snippet. Pure php ajax appears to work ok. Some processes appear to execute when invoked directly, but fail when the above ajax code is used. So i presume the binary itself is working, or would, if the php script were able to invoke it

Last edited by dogpatch; 08-16-2017 at 03:30 PM.
 
Old 08-16-2017, 10:36 PM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
http://php.net/manual/en/function.error-get-last.php
 
1 members found this post helpful.
Old 08-17-2017, 01:40 AM   #5
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
If you are not seeing any errors in the returned content, temporarily set PHP's error_reporting(...) to something more useful. If it is an ajax request then you need to look in your browser's javascript errors to see any returned error or hit the ajax target url in a separate tab.
 
Old 08-17-2017, 08:25 AM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,642
Blog Entries: 4

Rep: Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933
Well, for one thing, in the snippet you posted, there is no code to define any value for the variable, $php_errormsg ...
 
Old 08-17-2017, 12:41 PM   #7
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 490

Original Poster
Blog Entries: 4

Rep: Reputation: 238Reputation: 238Reputation: 238
All the above is moot, and i am inclined to mark this thread as 'solved', not because it is solved, but unsolvable, at least in any way that pertains to a programming thread. There are no errors reported by the server or php interpreter because according to the server nothing is amiss. What i believe has happened is that my hosting service has recently changed many server settings which i cannot alter, including the one which enables binaries in cgi-bin to be executed. Time to seek a better hosting service, no?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using PHP - simplexml_load_file w/ AJAX call - returns out of memory pizzipie Programming 2 11-19-2015 08:38 PM
missing php-cgi binary vitasis Linux - Server 2 09-01-2011 01:13 PM
Compile php into a static cgi binary txyoji Linux - Software 6 06-04-2009 09:10 AM
cgi-bin or module in php? RMLinux Red Hat 1 09-11-2008 08:44 AM
call perl cgi script from php j-ray Programming 2 01-14-2005 08:23 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration