954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

splitting a ftp connection string to it's parts

Hello everybody,

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

ftp://user:pass@host/path



the result should be smth like:

$USER = user
$PASS = pass
$HOST = host
$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

mfeldheim
Newbie Poster
1 post since Oct 2006
Reputation Points: 10
Solved Threads: 0
 
echo 'ftp://user:pass@host/path' | sed 's#[|:;>@/]# #g' | read dummy usr pwd hst pth
# or 
echo 'ftp://user:pass@host/path' | tr -s '/' ' ' | tr -s ':' ' ' | tr -s '@' ' ' | read dummy usr pwd hst pth
echo $pth
echo $pwd
echo $hst
echo $usr
jim mcnamara
Junior Poster
180 posts since May 2004
Reputation Points: 62
Solved Threads: 10
 

or else you can use the cut -c option to cut the string into its parts.

kamitsin
Newbie Poster
16 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You