Relative directory - NOT absolute


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Relative directory - NOT absolute
# 1  
Old 09-05-2002
Question Relative directory - NOT absolute

Here is the drill,
I am using a script to login to a remote ftp, and put and get files. My question is: I want to login and automatically change to the same directory I am in on my machine. I can not use $home, pwd or anyother env variable (that I know) since the names of the machines are totally different.
So, how can I know my relative directory path? ~/files/mac for instance.

I forgot to mention, I have the same directory tree on moth machines, so I have to copy the files to the same dir. (I will execute the script from the directory I want the file to be copied to)

btw (tcsh) thanks.
# 2  
Old 09-05-2002
See also

https://www.unix.com/shell-programming-and-scripting/4830-script-ftp-commands.html?s=


SET YOUR_DIR=`pwd`

/usr/bin/ftp <otherhost> <<END
verbose on
bin
user username password
cd <$YOURDIR>
mput <filenames*>
bye
END



Special thanks to Cameron
# 3  
Old 09-05-2002
Hi & 1ox 4 ur answer.

I did read this thread: https://www.unix.com/shell-programming-and-scripting/4830-script-ftp-commands.html?s= and this is exactly the script I am using, and it's great.
It's not answering my question.

user name: saarma
My local fill dir (pwd) is: sbusr13.n005/sbms/csm/saarma/Scripts

user name: sm3344
and my remote is: donald.d013/sbms/csm/sm3344/Scripts

so if I want to copy a file from home to remote, I can't use the pwd path, as it's not the same.
I need to know how to get the entire path after the user name.
All what's after: '~'

cheers
# 4  
Old 09-05-2002
This would be small change if you would switch to ksh:
${PWD#$HOME}

would do exactly what you want. For csh, maybe:
pwd | sed s=$HOME==
# 5  
Old 09-09-2002
MySQL

Perderabo 10x, works like a charm *
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Convert Relative path to Absolute path, without changing directory to the file location.

Hello, I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Discussion started by: Sekhar419
4 Replies

2. Shell Programming and Scripting

Show only the filenames under a directory without relative and absolute paths.

I am able to list all the filenames under a directory & its sub-directories except blent.tar on Linux find "/tmp/" -type f | grep -v blent.tar | rev | cut -d '/' -f1 | rev Desired Output: THIRDPARTYLICENSEREADME.txt javaws libjavaplugin_oji.so libjavaplugin_oji.so... (3 Replies)
Discussion started by: mohtashims
3 Replies

3. UNIX for Dummies Questions & Answers

How to convert relative path to absolute path?

Hello Everyone, I want to convert Relative Path - /home/stevin/data/APP_SERVICE/../datafile.txt to Absolute Path - /home/stevin/data/datafile.txt Is there a built-in tool in Unix to do this or any good ideas as to how can I implement this. -Steve (5 Replies)
Discussion started by: qwarentine
5 Replies

4. Shell Programming and Scripting

How to change Absolute path to Relative path

Hello, I have a doubt:- --------------------- Current script:- ################################################################################################ prefix=user@my-server: find . -depth -type d -name .git -printf '%h\0' | while read -d "" path ; do ( cd "$path" || exit $?... (4 Replies)
Discussion started by: sahil_jammu
4 Replies

5. UNIX for Dummies Questions & Answers

Assigning the relative directory name to a variable called $DIR.

Hi All, I've been trying to write a KSH script that acts on the name of the relative directory that this script is called from. In other words, if I am executing this script from a directory called: /hello/hithere/directory How would I assign DIR= to be "directory" and... (2 Replies)
Discussion started by: chatguy
2 Replies

6. Shell Programming and Scripting

absolute path for a script ran with relative path

I have a script in which i want to print absolute path of the same script irrespective of path from where i run script. I am using test.sh: echo "pwd : `pwd`" echo "script name: $0" echo "dirname: `dirname $0`" when i run script from /my/test/dir/struct as ../test.sh the output i... (10 Replies)
Discussion started by: rss67
10 Replies

7. UNIX for Dummies Questions & Answers

Absolute and Relative Paths?

Can someone cofirm that I have got the paths correct here? :confused: $PATH_TO_TMP_DIR='/tmp'; #$PATH_TO_TMP_DIR='home/tmp'; $PATH_TO_YOUR_IMG_DIR = '/temp_images'; #$PATH_TO_YOUR_IMG_DIR = 'home/public_html/Midwich/temp_images'; Thanks (1 Reply)
Discussion started by: stubie
1 Replies

8. UNIX for Dummies Questions & Answers

tar symlinks: relative vs absolute

I create the tar file from / like so: tar cEhf name.tar usr/us And this creates the tar with the links intact. The problem is that this tar is going to be used for testing, so we want the links to point to the files in the tar. But when I extract the tar into /tmp, I get /tmp/usr/us/... as I... (2 Replies)
Discussion started by: TreeMan
2 Replies

9. UNIX for Dummies Questions & Answers

Help with absolute path and relative path

I'm having problems accessing the Knoppix software on my current computer and the replacement CD I ordered hasn't arrived yet. I have a guess at what the answer would be for this question but I am not sure as I cannot test it with the software. I have to create a directory called class, and... (1 Reply)
Discussion started by: mzero
1 Replies

10. UNIX for Dummies Questions & Answers

vi - replacing a relative path with absolute path in a file

Hi, I have a file with about 60 lines of path: app-defaults/boxXYZ....... I want to change this to /my/path/goes/here/app-defaults/boxXYZ, but of course vi doesn't like the regualr :s/old/new/ command. Is there any other quick way to do this? Thanks ;) (2 Replies)
Discussion started by: Yinzer955i
2 Replies
Login or Register to Ask a Question