Go Back   CodingForums.com > :: Server side development > Perl/ CGI

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-19-2011, 10:37 AM   PM User | #1
sivarajan
New to the CF scene

 
Join Date: Jan 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
sivarajan is an unknown quantity at this point
Cool Perl Script running - No output - third party software

Hi,

I'm developing a server using CGI-perl. I'm a linux user. I made a CGI page nd i'm calling a perl script as a response to submit. I'm performing various tasks with in tat perl file using system() command, like given below

$cmd="perl abc.pl <input file>";
system($cmd);

When i tried to run a 3rd party software executable command (svm_classify) like this

$cmd="svm_classify <testfile> <modelfile> <outputfile>";
system($cmd);

the output file is not getting generated. but it says no error also.
The code is working fine when i run it. BUT IT IS NOT WORKING WHEN I RUN FROM SERVER (localhost)

Additional:
I tried to run that part alone as a perl script nd its working fine.
I tried to run that part from command line nd its working fine.

PLSSSSSSSS help me out!!!!!!!!!!

thanx a lot,
K. Sivarajan.
sivarajan is offline   Reply With Quote
Old 01-19-2011, 11:57 AM   PM User | #2
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by sivarajan View Post
Hi,

I'm developing a server using CGI-perl. I'm a linux user. I made a CGI page nd i'm calling a perl script as a response to submit. I'm performing various tasks with in tat perl file using system() command, like given below

$cmd="perl abc.pl <input file>";
system($cmd);

When i tried to run a 3rd party software executable command (svm_classify) like this

$cmd="svm_classify <testfile> <modelfile> <outputfile>";
system($cmd);

the output file is not getting generated. but it says no error also.
The code is working fine when i run it. BUT IT IS NOT WORKING WHEN I RUN FROM SERVER (localhost)

Additional:
I tried to run that part alone as a perl script nd its working fine.
I tried to run that part from command line nd its working fine.

PLSSSSSSSS help me out!!!!!!!!!!

thanx a lot,
K. Sivarajan.
try to use this instead of system:

http://search.cpan.org/perldoc/IPC::System::Simple

a classifier is usualy slow, i don't have experience with svm light but you need to check how long is running and if the server can run it so long time.

log everything you can and check logs to see what's happend.

best regards
oesxyl is offline   Reply With Quote
Old 01-19-2011, 03:17 PM   PM User | #3
sivarajan
New to the CF scene

 
Join Date: Jan 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
sivarajan is an unknown quantity at this point
Hi oesxyl,

it takes very less time(0.001seconds).

My problem is majorly it works as a script but it is not working when i run it from the server.
so i guess there is some hinderance in the server accessing the 3rd party software...
pls leave out svm_classify... jus tel for any third party softwares...


thanx,
K. Sivarajan.
sivarajan is offline   Reply With Quote
Old 01-19-2011, 04:40 PM   PM User | #4
FishMonger
Super Moderator


 
Join Date: May 2005
Location: Southern tip of Silicon Valley
Posts: 2,753
Thanks: 2
Thanked 149 Times in 144 Posts
FishMonger will become famous soon enoughFishMonger will become famous soon enough
Are you using the warnings and strict pragmas?
Code:
use strict;
use warnings;
If not then add them and declare all of your vars, which is done via the 'my' keyword.
Code:
my @cmd = ('svm_classify', '<testfile>', '<modelfile>', '<outputfile>');
system(@cmd) == 0
    or die "system @cmd failed: $?";
As shown above, you probably should use the list form of system.

Since this is a cgi script, while developing/debugging, you should also have:
Code:
use CGI::Carp qw(fatalToBrowser);
When a script works from the command line, but not when run as a cgi script, then in most cases that's due to the difference in the user environment. When run from the command line, it's running under your shell and privileges, but when run as a cgi script it's running under the web server user account and privileges.
FishMonger is offline   Reply With Quote
Old 01-19-2011, 05:07 PM   PM User | #5
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Code:
try to use this instead of system:

http://search.cpan.org/perldoc/IPC::System::Simple
Quote:
Originally Posted by sivarajan View Post
... jus tel for any third party softwares...
best regards
oesxyl is offline   Reply With Quote
Old 01-19-2011, 05:11 PM   PM User | #6
sivarajan
New to the CF scene

 
Join Date: Jan 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
sivarajan is an unknown quantity at this point
Thumbs up

Hi Fishmonger,

I tried what you have mentioned already... but in vain...

at last u have mentioned about the environment of web server... i exactly want to know about that only.

If u know pls tell me what should be modified/altered to make the 3rd party software run in the server???


thanx,
K. Sivarajan.
sivarajan is offline   Reply With Quote
Old 01-20-2011, 03:11 PM   PM User | #7
FishMonger
Super Moderator


 
Join Date: May 2005
Location: Southern tip of Silicon Valley
Posts: 2,753
Thanks: 2
Thanked 149 Times in 144 Posts
FishMonger will become famous soon enoughFishMonger will become famous soon enough
Specify the full path to the command and make sure that permissions are set correctly to allow the web server account to execute the program.

If the program requires any special environment settings, you can add them to Perl's built-in %ENV hash.
FishMonger is offline   Reply With Quote
Reply

Bookmarks

Tags
apache, httpd, perl-cgi, server

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:02 AM.


Advertisement
Log in to turn off these ads.