DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Shell Scripting (http://www.daniweb.com/forums/forum113.html)
-   -   splitting a ftp connection string to it's parts (http://www.daniweb.com/forums/thread59138.html)

mfeldheim Oct 24th, 2006 4:50 pm
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

jim mcnamara Oct 24th, 2006 5:33 pm
Re: splitting a ftp connection string to it's parts
 
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

kamitsin Nov 6th, 2006 2:50 am
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.


All times are GMT -4. The time now is 6:42 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC