Visit Our UNIX and Linux User Community


get symbolic link file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers get symbolic link file
# 8  
Old 11-13-2001
I don't have Shell access. Can I still tar the remote files?
# 9  
Old 11-13-2001
Question

I don't think so. Anyone know if this is possible?
# 10  
Old 11-13-2001
No, you can't tar without access to a shell. However I may have found a solution to this problem.

If you use the ftp commands "ls" or "dir" you will see a listing of the files in the directory. The symbolic links are identifable because of the leading l in the permissions and due to the "->" notation. So just write a script to do the ftp. It will do an "ls" and inspect the output. If it's a file, the script will get it. If it's a symlink, the script will simply recreate it.
# 11  
Old 11-13-2001
To add to Perderabo's approach...

use the "ls -tr" command assuming that the
link was created after the actual file.
This way, the "ls" command woun't sort
by name; it will sort by modification time
(reversed) and hopfully you will not see the link
listed before the actual file is.
However, this is also not foolproof and you may
have to get more sophisicated and trace the inode
back to the "real" file.

It should make for an interesting excercise. Smilie
# 12  
Old 11-13-2001
Quote:
Originally posted by rwb1959
It should make for an interesting excercise. Smilie
It did. Smilie

I have tested the first half of the script. You will need to alter the variables at the top. Also look at the the lines marked with a comment. Make sure that the top half is working before you try the bottom half. I didn't test the bottom half, but I think it should work....

Code:
#! /usr/bin/ksh

HOST=xxx.abc.com
USER=andrec
PASSWD=xyzzy
DIR=directory

LIST=""
IFS=""

{ ftp -n <<-!x
        open $HOST
        user $USER $PASSWD
        cd $DIR
        dir
        bye
!x
} | while read line ; do
        firstchar=$(echo "$line" |cut -c1)
        name=$(echo "$line" | cut -c55-)  #####  adjust the 55 
        case $firstchar in
        -)      echo $name is a real file
                if [[ -z $LIST ]] ; then
                        LIST=$name
                else
                        LIST="$LIST:$name"
                fi
                ;;
        l)      echo $name is a symlink
                one=${name%% *}
                two=${name##* }
                echo ln -s $one $two   ##### lose the echo
                ;;
        esac
done

exit    ##### remove me when first half is working

#
#  Get the files  (untested)

{
print  open $HOST
print  user $USER $PASSWD
print  cd $DIR

IFS=":"
for name in $LIST ; do
        print  get $name
done
print  bye ;  } | ftp -n

exit 0

 

Previous Thread | Next Thread
Test Your Knowledge in Computers #361
Difficulty: Medium
The rmdir command remove directories, even if they are not empty.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Tomcat 6.0 fails to read symlink(symbolic link) file

Hello all experts, Im in a situation where Tomcat simply does not want to read this file through the symlink.... I checked permissions..OK Also checked file & tomcat owner...all OK. This is what I have my /tomcat/conf/Catalina/local/appname.xml <Context> <Resource name="jdbc/black" ... (3 Replies)
Discussion started by: KingaKoopa
3 Replies

2. UNIX for Dummies Questions & Answers

Symbolic link

Hi, trying to understand more about symblic link, when I compiled a program called "match" in one folder ~/downloadsoftware/I want this program to be accessible like a system command by putting a symbolic link in /usr/bin/ Not by setting the $PATH method in .bashrc at this time. What I did is:... (4 Replies)
Discussion started by: yifangt
4 Replies

3. UNIX for Dummies Questions & Answers

[Solved] Symbolic link not allowed or link target not accessible

Hi everybody, I read about treads realted to this issue but they did not resovle issue given below. Please help me resolve issue given below I have html file under /srv/www/htdocs/actual_folder ls actual_folder/ test.html and following link works... (0 Replies)
Discussion started by: newbielgn
0 Replies

4. Shell Programming and Scripting

ls on a symbolic link

Hi all, Can anyone please confirm if the command below is the only way that I can get what the symbolic link is set to? mnlxd110(oracle)/db/posd2/dba$: ls -l | grep "^l" lrwxrwxrwx 1 oracle dba 28 Aug 9 2011 bdump -> diag/rdbms/posp1/posp1/trace mnlxd110(oracle)/db/posd2/dba$:... (7 Replies)
Discussion started by: newbie_01
7 Replies

5. Shell Programming and Scripting

Symbolic link to an empty file shows size 2

Hi, I have created an empty file and a symbolic link to a file. But when I issue the following commands, I am getting the output 2. stat -c "%s" linkfile du -hb linkfile Why this is happening? (4 Replies)
Discussion started by: royalibrahim
4 Replies

6. Shell Programming and Scripting

symbolic link to an executable file

I have a script within my home folder and want to be able to execute it without using the sh command. I know that if it was in ~/bin and executable I could do it just by typing the file name, but would rather keep it in the current file structure I tried creating a soft link in ~/bin,... (5 Replies)
Discussion started by: Jaloopa
5 Replies

7. Shell Programming and Scripting

symbolic link

Hi, i am trying to create sym links on sles 11 , but it seems i am doing something wrong. oracle@tests:/u01/app/oracle/oradata/ACIS> pwd /u01/app/oracle/oradata/ACIS oracle@tests:/u01/app/oracle/oradata/ACIS> ln -s /db/ACIS/dbase/dbf/ /u01/app/oracle/oradata/ACIS/... (2 Replies)
Discussion started by: tonijel
2 Replies

8. UNIX for Dummies Questions & Answers

How to find .dat file in symbolic link

Hi, I am trying to find all files in a directory that have .dat and .int extensions and removing them. rm -f `find ${MY_DIR} -type f -name '*.dat' -o -name '*.int'` This works fine if $MY_DIR is a regular directory. However when $MY_DIR is a symbolic link then this command fails. How... (1 Reply)
Discussion started by: neeto
1 Replies

9. UNIX for Dummies Questions & Answers

need some info about symbolic link and hard link

hello folks how y'all doin well i have some questions about symbolic link and hard link hope some one answer me i open terminal and join as root and i wrote ln -s blah blah then i wrote ls i see red file called blah blah but didn't understand what is this can some one explain and... (2 Replies)
Discussion started by: detective linux
2 Replies

10. UNIX for Dummies Questions & Answers

symbolic Link

question abt symbolic link ... i'm doing the following ... ln -s x.sh ./scripts/y.sh and cat ./scripts/y.sh it is giving following error cat: cannot open y.sh Any reason u an think of ? But it is working fine when i goto scripts directory and cretae the symbolic link. ... (1 Reply)
Discussion started by: bhargav
1 Replies

Featured Tech Videos