November 22, 2024, 05:07:02 PM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: Shell Script  (Read 8306 times)

Offline gauravbajaj

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 658
Shell Script
« on: January 24, 2006, 02:26:32 AM »
Hi Grp...
I have a pb , may be anyone can help me...

I want  some idea ..Actually i am a writing a shell script for my Project ..

In m project there are various customers like J090 C098 etc.(These are customers code no's)

In that , each customers has log directories ...in location say /mnt/logs/custcode/optindexes
{ where custcode is replaced by codes of customers like J090 , C098 etc)

These logs are automatically running , means  

we have a soft index named indexui , whose position is like this
 its in custcode directory

#indexui->/mnt/logs/custcode/optindexes/logs-23-01-2006

In above link the indexui is automatically updated to latest log directory like logs-23-01-2006(present date directory) , but some times it happens that it is not able to update i.e not link to latest logs directory...

so for that i have to check manually wheather link is updated to latest logdir or not..
So for that i m writing a script ,which shows "link is updated" if indexui links to updated log directory and shows "error" if its not able to update

..I checks links of all customers daily for updataion ..
So plz anyone help me how to check the links ,wheather it link to latest log directory or not ,



So help me plzzz, if anyone have idea to write this type of script

Thxx
gaurav bajaj

Offline dragoncity99

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 551
Shell Script
« Reply #1 on: May 07, 2006, 12:49:30 PM »
The trick to see if the log whether it's up to date or not is:

1. Store current date/time in a variable

2. Use ls & awk to get the date/time:

ls -ltr /path/to/link/your-link-name | awk '{$X}'

3. Compare it.

And ur done, u get the latest.

Offline gauravbajaj

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 658
Shell Script
« Reply #2 on: May 08, 2006, 05:19:11 AM »
Hi Dragoncity
 
Thx for the reply

But i did it already.. using shell scripting, i haven't used awk, but did it using  cut operator

Gaurav

Offline dragoncity99

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 551
Shell Script
« Reply #3 on: May 08, 2006, 06:38:09 AM »
Oh ic, u can take a look at awk script bro, it's slightly more convenient when dealing with white spaces or tabs.

I used to use cut for my scripts, but later on i found that awk is much flexible. Therefore i switched to awk.

:)

Offline gauravbajaj

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 658
Shell Script
« Reply #4 on: May 08, 2006, 07:48:17 AM »
Hi Dear
But I haven't used awk much, Can u give me any good link for awk tutorials?

Thanks
Gaurav

Offline dragoncity99

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 551
Shell Script
« Reply #5 on: May 08, 2006, 07:51:31 AM »
Here's a quick one:
http://stud.wsi.edu.pl/~robert/awk/

and:

http://www.vectorsite.net/tsawk.html

;)

Offline gauravbajaj

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 658
Shell Script
« Reply #6 on: May 08, 2006, 09:34:32 AM »
Thanks Bro