Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    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

  • #3
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,871
    Thanks
    2
    Thanked 164 Times in 159 Posts
    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.

  • #5
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    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

  • #6
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #7
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,871
    Thanks
    2
    Thanked 164 Times in 159 Posts
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •