Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

ksh Script to Generate Symbolic Links

Shell Programming and Scripting


Tags
unix commands

Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 05-08-2006
dwisconbug dwisconbug is offline
Registered User
 
Join Date: May 2006
Last Activity: 14 May 2006, 10:00 AM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ksh Script to Generate Symbolic Links

I'm writing a ksh script which will reference a text file I have to create symbolic links for my application:

--file contents--
Link Directory Link Source Link Name
/users/05/dwisconbug bin link2bin


Now, this should create the following link

link2bin -> /users/05/dwisconbug/bin

Before the script creates the symbolic link "link2bin" it needs to see if the link already exists - I know with brute force i can just delete the current link and recreate it, but I want to make sure the current link is pointing to the right source.

How do I use ksh/Unix commands to:

1) "ls -l link2bin" and awk(?) to grab the "link2bin-> /users/05/dwisconbug/bin"

2) If I set the contents of my file to the variables $link_dir, $link_src, and $link_nm generate what I expect the link to look like

3) somehow diff the results from steps #1 and steps #2 to make sure the existing link matches what I have listed in my file?

Any ideas? Thanks in advance!

PS: as you can imagine I need to get this working by the end of the day - so any help is appreciated!
Sponsored Links
    #2  
Old Unix and Linux 05-08-2006
dwisconbug dwisconbug is offline
Registered User
 
Join Date: May 2006
Last Activity: 14 May 2006, 10:00 AM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Please note for step #1 I'm thinking about exttracting:

dev123(69): ls -lp ffa
lrwxrwxrwx 1 dwisc g1 19 Mar 7 09:13 link2bin -> /users/05/dwisconbug/bin

I want to awk(?) "link2bin -> /users/05/dwisconbug/bin" so I can compare it to the contents of the file - that is of course after I modify the file contents to look like

diff2= cat '${link_nm} -> ${link_dir}/${link_src}' (will this do the trick?)

Thanks
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to change symbolic links via script smitty11 Shell Programming and Scripting 3 10-21-2009 08:21 AM
Symbolic Links cyberfrog UNIX for Dummies Questions & Answers 4 10-08-2009 12:02 PM
Symbolic Links - BASH Script rodrimuino Shell Programming and Scripting 4 09-05-2007 10:42 PM
Symbolic Links rcarnesiii AIX 1 08-17-2005 02:57 PM
cp a dty without symbolic links? JAKEZ Solaris 7 09-21-2004 12:55 PM



All times are GMT -4. The time now is 02:57 PM.