944,144 Members | Top Members by Rank

Ad:
Oct 24th, 2006
0

splitting a ftp connection string to it's parts

Expand Post »
Hello everybody,

I've got a small problem
I need the following string to be split into it's parts:

Shell Scripting Syntax (Toggle Plain Text)
  1. ftp://user:pass@host/path
the result should be smth like:

Shell Scripting Syntax (Toggle Plain Text)
  1. $USER = user
  2. $PASS = pass
  3. $HOST = host
  4. $PATH = path
Somebody has help for me?
Would be nice

Alternative I could also use a ftp shell enabled ftp client that "eats" the whole string (like old ncftp versions)

I can't use ncftpget / put because:
1. I want to delete files on the target server
2. The target server is a microsoft machine and doesnt work with with ncftput :mad:

kind regards

Michel
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mfeldheim is offline Offline
1 posts
since Oct 2006
Oct 24th, 2006
0

Re: splitting a ftp connection string to it's parts

Shell Scripting Syntax (Toggle Plain Text)
  1. echo 'ftp://user:pass@host/path' | sed 's#[|:;>@/]# #g' | read dummy usr pwd hst pth
  2. # or
  3. echo 'ftp://user:pass@host/path' | tr -s '/' ' ' | tr -s ':' ' ' | tr -s '@' ' ' | read dummy usr pwd hst pth
  4. echo $pth
  5. echo $pwd
  6. echo $hst
  7. echo $usr
Last edited by jim mcnamara; Oct 24th, 2006 at 5:54 pm.
Reputation Points: 62
Solved Threads: 10
Junior Poster
jim mcnamara is offline Offline
179 posts
since May 2004
Nov 6th, 2006
0

Re: splitting a ftp connection string to it's parts

or else you can use the cut -c option to cut the string into its parts.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kamitsin is offline Offline
16 posts
since Apr 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: how to mount to serial port??wat is the command?
Next Thread in Shell Scripting Forum Timeline: query regarding the crontab command





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC