|
#1
| ||||
| ||||
| cron tab help i am making a script that uploads my ip address to a website. It works perfectly when run from terminal. The shell i am using is sh Code: ifconfig | tail -1 | tr " " "\n" | head -2 | tail -1 however when this is run from the cron tab at the specfied time it outputs nothing, rendering my script useless. WHY??? by the way is there a better way of getting the ip address off interface ppp0?
__________________ | PowerBook G4 550 - 10.4 - 512Mb - 20Gb | 30Gb iPod Photo | 40x12x48 Fantom Drives CDRW (firewire) | Logitech Cordless Mouse MX700 | xBox with XBMC for movies and music in the lounge |
|
#2
| ||||
| ||||
| This is a better way IMHO. I did exactly this about a month ago. The shell script: Code: #!/bin/tcsh
cd /Users/gwailo/update_ip
nice +20 date > ip.txt;
nice +20 echo "<br>" >> ip.txt;
nice +20 echo "Current WAN IP Address: <br><b>" >> ip.txt;
nice +20 /sbin/ifconfig ppp0 | grep inet | awk '{print $2}' >> ip.txt;
#date >> log.txt
nice +20 ftp ftp.domain.com < connect.ftp >> ftp_log.txt Code: type ascii cd Sites/ip put ip.txt index.html bye Note that this also assumes that you have ~/.cshrc configured so that it can login via ftp automatically, without having to leave the username and password in cleartext in the script. Maybe move this to HOW-TO & FAQs? ![]()
__________________ michaelsanford.com Blog Twitter Tumblr LinkedIn iMac Aluminum 24" | MacOS X 10.5-current | 3.06 GHz Intel Core Duo | 4 GB RAM | 1 TB HDD iBook G4 1.42 GHz | MacOS X 10.5-current | 1 GB RAM, 100 GB HDD AMD Athlon64 3500+ | Slackware 12 (2.6.21.5-smp) | 2 GB RAM, 2120 GB RAID 1, 2500 GB RAID 0 |
|
#3
| ||||
| ||||
| Attached is my script. It creates a formatted html page with the date and your ip and uploads to a ftp server - just put in your ftp host, username and password All you need to do is add a cron job to make it automaticaly run every hour or so! Anyone know how to make a script run when the dialup ppp connection is made? I know OSX runs a few scripts because you can see 'sh' run a few times in top. That would be the perfect solution!! You might want to rename the attachment to have a .sh extention for 'proper' form. I have made this an invisible file in my home directory by naming it .ipupload.sh.
__________________ | PowerBook G4 550 - 10.4 - 512Mb - 20Gb | 30Gb iPod Photo | 40x12x48 Fantom Drives CDRW (firewire) | Logitech Cordless Mouse MX700 | xBox with XBMC for movies and music in the lounge |
|
#4
| |||
| |||
| What's probably failing in your cron job is that those jobs run with a different PATH than your login shell. You can experimentally verify it with a crontab entry like: Code: 30 * * * * env | mail -s env youremail Code: PATH=/sbin:/bin:/usr/sbin:/usr/bin
__________________ Author, Learning Unix for Mac OS X (O'Reilly), among other books. Check out http://books.intuitive.com/ |
|
#5
| ||||
| ||||
| i gave the full path to ifconfig in the script and now it works correctly. Thanks anyway!!
__________________ | PowerBook G4 550 - 10.4 - 512Mb - 20Gb | 30Gb iPod Photo | 40x12x48 Fantom Drives CDRW (firewire) | Logitech Cordless Mouse MX700 | xBox with XBMC for movies and music in the lounge |
![]() |
| Thread Tools | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Cron Help Please | emh_alpha1 | Unix & X11 | 7 | October 26th, 2002 01:14 PM |
| Terminal: Where have thy tab completion gone? | reverendsin | Unix & X11 | 3 | August 27th, 2002 09:53 AM |
| cron process not starting up | sinebubble | Mac OS X System & Mac Software | 2 | March 11th, 2002 01:10 AM |
| How do you get cron to work? | buc99 | Mac OS X System & Mac Software | 1 | January 2nd, 2002 04:32 PM |
| mysqldump and cron | aussieron | Mac OS X System & Mac Software | 2 | November 6th, 2001 05:45 PM |