The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Expect script on crontab ap1030 Shell Programming and Scripting 6 06-04-2009 01:09 PM
will this script in crontab effect SUN 9?? thepurple SUN Solaris 2 10-05-2007 04:31 AM
recurring run of sh script in crontab MarGur Shell Programming and Scripting 4 05-07-2007 07:42 PM
Using a script to modify the crontab johnmsucpe UNIX for Dummies Questions & Answers 2 07-07-2005 02:44 PM
how can i use crontab in a script? DebianJ Shell Programming and Scripting 1 05-05-2005 09:24 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-16-2008
moutaz1983 moutaz1983 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 24
Crontab a Script

I know my question maybe eazy, but it realy cause a problem for me

I have a Perl script to run and get some output, I run this script using perl /moutaz/ciscolog/telnet.pl

I made another script as follow/moutaz/ciscolog/script)
#!/bin/bash
perl /moutaz/ciscolog/telnet.pl
cp /moutaz/ciscolog/ciscolog /moutaz/ciscolog/ciscolog-$(date'+%H-%M')-$RANDOM

Then made crontab as follow:
15 * * * * /moutaz/ciscolog/script

The question:
-when apply command from shell it worked fine.
- from crontab it doesn't, only the cp command work.

what is the problem?
  #2 (permalink)  
Old 01-16-2008
ennstate ennstate is offline
Registered User
  
 

Join Date: Mar 2007
Location: Chennai
Posts: 222
May it was not able to find the Perl executable path.
Can you try the same by giving the full path to perl in your script?

Thanks
Nagarajan G
  #3 (permalink)  
Old 01-16-2008
moutaz1983 moutaz1983 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 24
Thanks for your reply.

But it is exactly what I did.

In script which run from crontab: perl /moutaz/ciscolog/telnet.pl
Also in cron tab /moutaz/ciscolog/script

Even I tried to put in Cron perl /moutaz/ciscolog/telnet.pl it doesn't work

It is weird, I don't know what is the issue.
  #4 (permalink)  
Old 01-16-2008
dinomite dinomite is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 1
You need to put the full path to the Perl interpreter not just your script. You probably want:

/usr/bin/perl /moutaz/ciscolog/telnet.pl

in the script.
  #5 (permalink)  
Old 01-16-2008
moutaz1983 moutaz1983 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 24
Unfortunantely, It also didn't work also.
  #6 (permalink)  
Old 01-16-2008
ennstate ennstate is offline
Registered User
  
 

Join Date: Mar 2007
Location: Chennai
Posts: 222
Quote:
Originally Posted by moutaz1983 View Post
I know my question maybe eazy, but it realy cause a problem for me

I have a Perl script to run and get some output, I run this script using perl /moutaz/ciscolog/telnet.pl

I made another script as follow/moutaz/ciscolog/script)
#!/bin/bash
perl /moutaz/ciscolog/telnet.pl
cp /moutaz/ciscolog/ciscolog /moutaz/ciscolog/ciscolog-$(date'+%H-%M')-$RANDOM

Then made crontab as follow:
15 * * * * /moutaz/ciscolog/script

The question:
-when apply command from shell it worked fine.
- from crontab it doesn't, only the cp command work.

what is the problem?

Why dont you try redirecting the cron output to some log file
Code:
 15 * * * * /moutaz/ciscolog/script >> /tmp/cron.log 2>&1
If in the perl script ( /moutaz/ciscolog/telnet.pl ) you may have used the perl instead of full path to perl,try that too

Thanks
Nagarajan G
  #7 (permalink)  
Old 01-16-2008
moutaz1983 moutaz1983 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 24
Yes, It helped alot.

The error file contain the following:

Can't locate Net/Telnet.pm in @INC (@INC contains: /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5 /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4 /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2 /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at /moutaz/ciscolog3/telnet.pl line 4.
BEGIN failed--compilation aborted at /moutaz/ciscolog3/telnet.pl line 4.

I think this will limit the problem.

The perl script is using Net::Telnet to make telnet to routers, So what do you think the problem?
Closed Thread

Bookmarks

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes 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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:15 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0