splitting a ftp connection string to it's parts

Reply

Join Date: Oct 2006
Posts: 1
Reputation: mfeldheim is an unknown quantity at this point 
Solved Threads: 0
mfeldheim mfeldheim is offline Offline
Newbie Poster

splitting a ftp connection string to it's parts

 
0
  #1
Oct 24th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 178
Reputation: jim mcnamara is on a distinguished road 
Solved Threads: 10
jim mcnamara jim mcnamara is offline Offline
Junior Poster

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

 
0
  #2
Oct 24th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 16
Reputation: kamitsin is an unknown quantity at this point 
Solved Threads: 0
kamitsin kamitsin is offline Offline
Newbie Poster

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

 
0
  #3
Nov 6th, 2006
or else you can use the cut -c option to cut the string into its parts.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC