Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 20 Aug 2014, 03:08
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Right click to find symbolic link
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
don570


Joined: 10 Mar 2010
Posts: 3250
Location: Ontario

PostPosted: Thu 02 Aug 2012, 19:08    Post_subject:  Right click to find symbolic link  

Forum member SFR has a neat and simple method to
discover if icon is a symbolic link to a folder ( or to an
ordinary file).

He used it in Large file finder
http://murga-linux.com/puppy/viewtopic.php?t=77779

I used it in the script create-3mu found HERE

The 'find' command won't work if the location given
is a symbolic link. So getting the real location is important.

Code:

FPATH="$1"
TEST=`stat -c %F "$FPATH"`
if [ "$TEST" = "symbolic link" ]; then
  FPATH=`stat -c %N "$FPATH" | cut -f3 -d '\`'`
  FPATH=${FPATH%?}
fi



Explanation: FPATH is path of the folder(or file).
After execution of the code it will be the path to the real folder(or file)

The variable TEST will contain the text "symbolic link" if
the user has right clicked on a symbolic link.

In the special case of the symbolic link and the real file being
in the same folder -----> just the real name is returned.

___________________________________________

__________________________________________________
Back to top
View user's profile Send_private_message 
RSH


Joined: 05 Sep 2011
Posts: 2376
Location: Germany

PostPosted: Fri 03 Aug 2012, 10:36    Post_subject:  

Hi.

Code:
FPATH="$1"
TEST=`stat -c %F "$FPATH"`
if [ "$TEST" = "symbolic link" ]; then
  FPATH=`stat -c %N "$FPATH" | cut -f3 -d '\`'`
  FPATH=${FPATH%?}
fi

This is exactly the solution to something i am currently working on. The LazY Puppy Run-Script-GUI (Starter) shows only symbolic links to the Run-Scripts in a different directory. I do use this now to remove these symbolic links and its Run-Scripts (including the directory) from within the Run-Script-GUI.

Code:
FPATH="$Progs$TREEOUTPUT"
TEST=`stat -c %F "$FPATH"`
if [ "$TEST" = "symbolic link" ]; then
   FPATH=`stat -c %N "$FPATH" | cut -f3 -d '\`'`
   FPATH=${FPATH%?}
fi
dbn=`dirname $FPATH`
rm -r $dbn
rm $Progs$TREEOUTPUT

Thanks a lot to don570 and to SFR.

RSH

_________________
LazY Puppy
RSH's DNA
SARA B.
Back to top
View user's profile Send_private_message 
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Fri 03 Aug 2012, 16:15    Post_subject:  

Another way is to use readlink -

Code:
 [[ `readlink "$1"` ]] && FPATH=`readlink "$1"` || FPATH="$1"


Cheers,
s
(Or readlink -e if recursion needed)
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0531s ][ Queries: 11 (0.0073s) ][ GZIP on ]