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 Sat 20 Dec 2014, 02:35
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 [3 Posts]  
Author Message
don570


Joined: 10 Mar 2010
Posts: 3437
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: 2420
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: 888

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 from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


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