View Single Post

  #8 (permalink)  
Old 07-13-2007, 07:01 PM
Ali_ix's Avatar
Ali_ix Ali_ix is offline
Junior Member
User
 
Join Date: Jul 2007
Location: Iran, Tehran
My distro: Debian/Ubuntu
Posts: 6
Rep Power: 0
Ali_ix is on a distinguished road
Send a message via Yahoo to Ali_ix
Default

please wrap code with code tag! ([ code ] [ /code ] without space in bracket

Quote:
Originally Posted by SAYAYINX View Post
I will use my line then:

MYIP=`curl -s IP Chicken - What is my IP? Find Your IP Address! | awk '/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/ {print $1}'`
I know it works.
yes, this works, but this work better:

Code:
curl -s http://www.ipchicken.com/ | awk '/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/ {print $1}' | uniq
Quote:
Originally Posted by SAYAYINX View Post
But I have another question:
LOG=/your/log/path/ip <= where is that folder? can i make one up?
OLD_IP=`cat $LOG` <= again, is that a folder? a file?
you should create the folder and enter full path here.
i have a 'scrpts' folder in my home director. and save log file with a 'log_' prefix with script name there.

ex:
script: /home/ali/scripts/ip_change
log file: /home/ali/scripts/log_ip_change

i have assigned the log file path to LOG variable in script, the in used 'LOG' variable as parameter to 'cat' command to read file content and assigned the result to 'OLD_IP' variable.

you just need to define 'LOG' variable. the LOG variable points to a file.
Reply With Quote