LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 07-13-2005, 08:36 PM   #1
lt_wentoncha
Member
 
Registered: Apr 2005
Posts: 42

Rep: Reputation: 15
cron and shell env variables


Hi all,

I have this scrip that I wanted cron to run hourly, it's a script that wgets to zoneedit dns servers to update my dynamic IP addy on their dns servers. So I put in the script:

echo wget -o ..
wait
exit

It echoes the command to shell but I don't think it exectutes this, as if it's just echoing the command rather than executing it whenever I do ./script in the shell in the current directory of the script.

I already setup the following in crontab:

59 * * * * * * some_user run-parts /"directory of script"

and it confirms my suspicisons that the script isn't right. How do I go about setting up the script so that it runs the commands in it? Better yet, how do I setup crontab to exec the script only when my IP address from my ISP changes?

Also, hwo do I go about permanently changing environment variables for X Terminal, Konsole, and bash shells?

Many, many thanks.
 
Old 07-13-2005, 09:53 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
When setting up cron jobs always assume that cron starts you script in never-never land. You should put full paths in front of all your executables and done use .. as a directory unless you cd there first.
Code:
cd <some dir>
echo /usr/bin/wget ..
wait
exit
Cron can't be setup to run a script when your IP changes. It's not his job to do so. It only executes based on time.

Permanently set env variabels by either putting them in /etc/profile (system wide) or add them to /home/user/.profile or /home/user/.bashrc (.bashrc if you use the bash shell)
 
Old 07-13-2005, 11:11 PM   #3
lt_wentoncha
Member
 
Registered: Apr 2005
Posts: 42

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by crabboy
When setting up cron jobs always assume that cron starts you script in never-never land. You should put full paths in front of all your executables and done use .. as a directory unless you cd there first.
Code:
cd <some dir>
echo /usr/bin/wget ..
wait
exit
Cron can't be setup to run a script when your IP changes. It's not his job to do so. It only executes based on time.

Permanently set env variabels by either putting them in /etc/profile (system wide) or add them to /home/user/.profile or /home/user/.bashrc (.bashrc if you use the bash shell)
Hmmmmm, adding in the cd (cd / or echo cd /) didn't work.

Code:
(change directory)
echo wget -O - --http-user=username --http-passwd=password 'http://dynamic.zoneedit.com/auth/dynamic.html?host=www.mydomain.com' 
wait
exit
Normally, if I just run the command in shell, some processing would be done and something like this gets output to shell:
Code:
--21:48:23-- »https://dynamic.zoneedit.com/auth/dynamic.html..
=> `-'
Resolving dynamic.zoneedit.com... 69.72.142.98
Connecting to dynamic.zoneedit.com[69.72.142.98]:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 101 [text/html]

0% [ ] 0 --.--K/s 
100%[====================================>] 101 --.--K/s

21:48:23 (320.24 KB/s) - `-' saved [101/101]
But if I do ./"script" it just echoes

Code:
wget -O - --http-user=username --http-passwd=password 'http://dynamic.zoneedit.com/auth/dynamic.html?host=www.mydomain.com'
Any other suggestions? Thanks you very much for replying.
 
Old 07-14-2005, 01:39 PM   #4
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
The script you posted only has a 'echo wget ' so the output of:

wget -O - --http-user=username --http-passwd=password 'http://dynamic.zoneedit.com/auth/dynamic.html?host=www.mydomain.com'

would be correct. What results do you get without the echo in front of wget?
 
Old 07-16-2005, 01:15 PM   #5
lt_wentoncha
Member
 
Registered: Apr 2005
Posts: 42

Original Poster
Rep: Reputation: 15
Sorry, my DSL was down but now it's back up.

Anyways, when I echo that command, I don't get the ouput I should get. It seems to just litterally write that command in console and not execute it. Any thoughts?

Thanks again.
 
Old 07-16-2005, 01:20 PM   #6
mhallbiai
Member
 
Registered: Jun 2005
Posts: 96

Rep: Reputation: 16
crabboy is correct, echo is doing what it is designed to do 'echo' the string to stdout (unless otherwise specified).

so echo wget with options will return wget with options to stdout.
if you are actually wanting to run wget with option then you won't need to use echo before it in your script.

hope this helps
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
setting env. variables arunsri Slackware 3 03-26-2005 05:49 AM
Ent 9.0 + eDir 8.8 (env variables not holding) suncloud SUSE / openSUSE 1 03-11-2005 12:48 PM
where are the env variables set on boot? Pete Dogg Linux - Software 1 09-10-2003 02:37 AM
setting env variables globally raven Linux - General 6 02-21-2003 08:04 AM
Open GL env.variables UB_KMA Linux - Newbie 1 08-04-2002 05:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 12:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration