Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 7 of 7

This is a discussion on can anyone figure out why simple command file won't run? in the Shared & Semi-Dedicated forum
This may be in relationship to my cron job problem, and makes me think something in my account is majorly hosed. I've got a perl ...

  1. #1
    JPC Member
    Join Date
    Mar 2003
    Posts
    9

    can anyone figure out why simple command file won't run?

    This may be in relationship to my cron job problem, and makes me think something in my account is majorly hosed.

    I've got a perl file hw.pl as follows:

    #!/usr/bin/perl
    print "Hello World!\n" ;
    exit(0);

    This is sitting in my cgi-bin directory.

    I have no problem executing it with

    perl hw.pl (if sitting in cgi directory)

    or

    perl /home/beartopi/www/cgi-bin/hw.pl (if sitting elsewhere)

    Now I've created a CGI file to execute this perl file, the CGI is called hw.cgi:

    #!/bin/sh
    perl /home/beartopi/www/cgi-bin/hw.pl

    I try executing it from the command line in my cgi directory as follows:

    ./hw.cgi

    and I get bash: /hw.cgi: bad interpreter: No such file or directory.

    I've got other cgi files, set up identically, that do work on the command line.

    I am trying to set up a simple test case for Tech Support for my cron job problem and now I cannot even get this to run.

    All my .cgi and .pl file permissions are at 755.

    Is there anything real obvious that I am missing??!!??

  2. #2
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    First of all, there really is no reason to have separate pl and cgi files. Just set your perl permissions to 755 and add

    #!/usr/bin/perl

    as the first line of the file. Then they will will run from the command line without needing to add "perl" at the beginning of the command line.

    As for the "bad interpreter" issue, did you upload the cgi file via ftp? If so, it kind of looks like you didn't upload it as ASCII Text.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  3. #3
    JPC Member
    Join Date
    Mar 2003
    Posts
    9

    cgi is simplified

    Jason, thanks for your reply,

    I showed a greatly simplified version of what my cgi file does. To simplify what I specify as a cron job I use a cgi file. The cgi file then executes the perl, which redirects output to a text file, etc.

    I don't want to have to type perl with redirects in a cron job.

    Why not have a command cgi file that cron can run? It worked last week. My cron jobs stopped working, and this mess is escalating into something beyond my ability to fix.

    I could have sworn I saw a previous thread suggestion about setting up cron jobs to put "all" the commands in a cgi file, and just setting up the cron to run the command file. Why wouldn't that suggestion still be valid?

    I uploaded the file with ssh's scp. I also uploaded hw.pl with scp, but that runs.

  4. #4
    JPC Member
    Join Date
    Mar 2003
    Posts
    9

    Got hw.cgi to run!

    Jason!

    You got me thinking about scp. I tried plain vanilla ftp, and uploaded hw.cgi again.

    This time when I type ./hw.cgi, it runs!

    One problem down, one to go.

    Thanks!

  5. #5
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    To run the a CGI script (as if it was bing run through the browser) in your cron job, just put GET in front of the command:

    GET http://www.yaddayadda.com/cgi-bin/somescript.cgi

    To run a script as if you were doing it from the command line, just put the path to the script in for the command:

    /home/username/somescript.pl

    I'm not sure if that will help you or not...

    Now,

    I don't want to have to type perl with redirects in a cron job.
    I'm not sure what you mean by this, but I'm going to take a guess. In your hw.cgi file, you called the perl file like this:

    perl /home/beartopi/www/cgi-bin/hw.pl

    In Unix, if you make a file executable (as you said you did with the hw.pl file) you can just run it from the command line without specifying a program. In your example, you are essentially telling the server "run a program called perl and open a file called hw.pl." When you tell perl to "open a file" it runs it. This is similar like you might do with pico or vi to edit a file:

    pico hw.pl

    In this example, you are telling the server to run pico instead of perl and open hw.pl. Pico is an editor, so in this case it reads the file and lets you edit it.

    When you make a file executable and place a line that starts #!, such as #!/bin/sh or #!/usr/bin/perl, you are telling the server to run the program specified on that first line and pass the contents of that file on to it. So #!/bin/sh says "open this file in sh" and #!/usr/bin/perl means "open this file in perl." So, all you need to do is type type

    ./hw.pl

    on the command line and you're in business.

    I still can't tell you anything about the cron problem. A tech, who has access to your account and can do some experimenting with it will have to help you out there. I can only share my experience.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  6. #6
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    OK, disregard what I said about not understanding your not wanting to run perl with redirects statement. While I was reading that I had 5 people walk into my office all needing different things while trying to eat my lunch. Now that I've gone back and read it again it is much clearer and I understand what you are saying.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  7. #7
    JPC Member
    Join Date
    Mar 2003
    Posts
    9

    redirect in file

    HI again Jason,

    What I mean is that I don't want my cron entry to look like this:

    ~/www/cgi-bin/myjob.pl arg1 arg2 arg3 arg4 arg5 > /home/beartopi/www/cgi-bin/myjob.txt

    It's too long and clumsy.

    I'd much rather have something like the above text, including invocation, arguments, and redirects, in myjob.cgi then have my cron entry simply say

    ~/www/cgi-bin/myjob.cgi

    I am able to get /.hw.cgi to work now, thanks to your reminder about uploading in binary versus text. And yes, this morning, I was able to execute hw.cgi as a cron job.

    Unfortunately photon seems really hosed and I still cannot get up to my account and figure out why my other scripts will no longer properly run as cron jobs. This whole mess started when I noticed that my cron jobs were trying to run but failing to write output (file sizes of output files were 0). They output just fine when run from the command line.

    I have not heard back from Jaguar about this so I have to assume they are working on it.

Bookmarks

Posting Permissions

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