Re: Calling a C++ binary from Perl
by sfink (Deacon) on May 13, 2005 at 22:29 UTC
|
Assuming this is running under Linux or some other OS with strace, I'd replace the call to the binary with strace -o /tmp/curseword.log -s800 ./binary arg1 arg2 (the curse word should be chosen appropriately for the length of time you have been struggling with this problem.) Then grep through the resulting log for the files that it is unable to find, and look to see how it is trying to access them and what error code it's getting back.
Assuming the worst case (namely, it accesses them with the expected relative paths and gets back ENOTFOUND), replace "binary" with a shell script that records its working directory to a log file before exec'ing the real, renamed binary with the given args.
If the problem remains a mystery, you might try checking the sign of the Zodiac under which the computer was first booted. Watch out, though -- it's easy to be fooled by OS reinstalls and calendar drifts.
| [reply] [d/l] |
Re: Calling a C++ binary from Perl
by mrborisguy (Hermit) on May 13, 2005 at 20:36 UTC
|
does your binary have relative paths to files? if you are calling it from a different directory, then maybe your effective directory is still in your cgi folder, and so the binary program is looking for files there, instead of somewhere relative to itself. just a thought.
also, it looks like you've probably got this covered, but is it have something to do with the user? because most webservers use a different user (like 'nobody' or 'apache'), so you may want to make sure your webserver's user as the correct permissions. | [reply] |
|
|
Yes, the binary does use relative paths, and I cannot change this fact unfortunately. I know the chdir command worked, because I invoke the c++ program by using a relative command (./programname).
The permissions have been validated from / on down, including directories and files. Everything is either 755 or 644. Thanks for your suggestions though!
| [reply] |
Re: Calling a C++ binary from Perl
by kwaping (Priest) on May 14, 2005 at 00:54 UTC
|
Thanks for the suggestions, everyone! I ended up viewing the contents of all the files in the directory that appeared to be config files and noticed there was a reference to /tmp in there. I checked /tmp and found a file belonging to the c++ application that needed to be a+w but wasn't... So it was permissions after all! | [reply] |
|
|
So your program requires a file in /tmp which all local users can write to?
Ouch - that sounds like sooner or later somebody is going to trash it, or remove it, and you'll be in trouble.
It might be worth seeing if you can set $ENV{'TMP'} to read the file from another directory instead..,
| [reply] |
|
|
Don't do that. Chances are that the file was created while you were testing your app with your account, but if the app is supposed to be executed only by the apache/nobody/whatever CGI user just change the file owner leaving the permissions as they are were before (you probably can afford pretty the same result simply removing the file and letting the application re-create it from scratch).
Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')
Don't fool yourself.
| [reply] |
Re: Calling a C++ binary from Perl
by rir (Vicar) on May 13, 2005 at 21:15 UTC
|
| [reply] [d/l] [select] |
Re: Calling a C++ binary from Perl
by kwaping (Priest) on May 14, 2005 at 17:40 UTC
|
Thanks Steve and Flavio, I'll try those suggestions when I get back into work on Monday. | [reply] |