Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running a Perl programs 1

Status
Not open for further replies.

MGreene

Programmer
Oct 2, 2001
9
US
I am new to Perl and Linux. My experience is to schedule a perl program from the cron scheduler. However a new program I just created won't run through cron, so I want to run it directly from the command, but I don't know what the command is. Can someone please help?
 
If the first line of the perl script is something like:

#!/usr/bin/perl OR
#!/bin/perl

Then it should run from the command line.

Can you provide details why cron won't run it, or what command you need specified ?

Bill.
 
I suggest for understanding why it doesn't work with cron.

You other question is very confusing; perhaps might help, or maybe this from
Why can't I run this program?


You can see it right there in your directory, but it keeps saying "Not found" when you try to run it. If you are "root", it's because root does not, by default and by design, have "." (the current directory) in its PATH, and unlike DOS, Unix shells don't assume that the current directory should be searched. Actually, ordinary users get "." in their PATH, but "root" does not, and the reason is security- to keep you from accidentally executing the wrong program. Type "./program" to get around this, or if you want to live dangerously, modify root's .profile and add ":." to the end of the PATH.

If it does the same thing when you do "./program", it's because the very first line of the script tells it to use some other program: for example, the script might have "#!/usr/bin/perl5" as its first line- if you don't have /usr/bin/perl5, you'll get that "not found" error (look at the line carefully- you might have /usr/local/bin/perl5 or /usr/bin/perl, for example, but close doesn't count here!).

If the error is "cannot execute", try "chmod +x program". Unix programs have to be marked as "executable". DOS does that by the program's extension (.BAT, .EXE, .COM), which is, as usual, dumb. All together now: DOS IS DUMB. Thanks.

It's also possible that your problem is related to LD_LIBRARY_PATH - This won't be the case for a script you make, but it could be for someone else's program. What that controls is where to search for shared libraries. Unix/Linux systems always have standard places to search, but sometimes need some help. See Why do I get "dynamic linker" errors or load failures? in the FAQ here.
Tony Lawrence
SCO Unix/Linux Resources tony@pcunix.com
 
Thanks to both of you for the info. I had not done chmod. It works now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top