|
Home > Archive > Unix Shell > April 2005 > Need to put backslash into a username in an FTP script
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Need to put backslash into a username in an FTP script
|
|
| billadams1@gmail.com 2005-04-28, 5:59 pm |
| I'm FTPing a file in a script to a Microsoft server which is requiring
me to use the domain-name with a backslash then the username. For
example:
ftp -i -n <<- EOF
open servername
user domain\username password
mput filename
close
quit
EOF
The Unix side doesn't like the backslash. It says "User domainusername
cannot login", so I used another backslash as an indicator:
user domain\\username password
No dice. So I tried single quotes:
user 'domain\username' password
Nada! Please help.
Thanks,
-ba
| |
| Alan Connor 2005-04-28, 5:59 pm |
| On comp.unix.shell, in
<1114707665.828981.193950@g14g2000cwa.googlegroups.com>,
"billadams1@gmail.com" wrote:
Okay. Since no one else has come up with a solution here,
I'll just rattle off some thoughts on the subject.
> I'm FTPing a file in a script to a Microsoft server which is
> requiring me to use the domain-name with a backslash then the
> username. For example:
>
> ftp -i -n <<- EOF
> open servername
> user domain\username password
> mput filename
> close
> quit
> EOF
>
> The Unix side doesn't like the backslash. It says "User
> domainusername cannot login", so I used another backslash as an
> indicator:
>
> user domain\\username password
>
> No dice. So I tried single quotes:
>
>
> user 'domain\username' password
I'd quote the entire right side.
>
> Nada! Please help.
>
>
> Thanks, -ba
>
If you are getting past the unix side with the quotes,
maybe it's the usual M$ requirement for CRLF line
terminations that's the problem.
You might try adding the CRs with ^V^M in vi.
Or use a more sophisticated and modern ftp client, like
ncftp, which is excellent and comes with utilities to
facilitate the use of scripts. It's free.
http://www.ncftp.com
HTH,
AC
--
alanconnor AT earthlink DOT net
Use your real return address or I'll never know you
even tried to mail me. http://tinyurl.com/2t5kp
| |
| Stephane CHAZELAS 2005-04-28, 5:59 pm |
| 2005-04-28, 10:01(-07), billadams1@gmail.com:
> I'm FTPing a file in a script to a Microsoft server which is requiring
> me to use the domain-name with a backslash then the username. For
> example:
>
> ftp -i -n <<- EOF
> open servername
> user domain\username password
> mput filename
> close
> quit
> EOF
>
> The Unix side doesn't like the backslash. It says "User domainusername
> cannot login", so I used another backslash as an indicator:
>
> user domain\\username password
>
> No dice. So I tried single quotes:
>
>
> user 'domain\username' password
>
> Nada! Please help.
[...]
Try user domain\\\\username password
or <<- \EOF
user domain\\username password
EOF
or <<- \EOF
user "domain\username" password
EOF
You probably need to double the backslash both for the shell and
for ftp.
--
Stéphane
| |
| David Weintraub 2005-04-28, 5:59 pm |
|
billada...@gmail.com wrote:
> I'm FTPing a file in a script to a Microsoft server which is
requiring
> me to use the domain-name with a backslash then the username. For
> example:
>
> ftp -i -n <<- EOF
> open servername
> user domain\username password
> mput filename
> close
> quit
> EOF
>
> The Unix side doesn't like the backslash. It says "User
domainusername
Instead of trying to do this in shell, try using the .netrc file. FTP
scripts can be setup via the .netrc file. You set this file up with the
permissions r-------- in your $HOME directory. Basically it looks like
this:
machine <servername> login <domain\username> password <password>
macdef init
mput <filename>
close
quit
<blank line>
The "macdef init" defines a macro that will automatically execute on
connection. The blank line ends the definition of the macro.
You can put multiple definitions in a single .netrc file:
machine ftp.foo.com login myfoo password swordfish
macdef init
bin
hash
prompt
cd /pub/mydir
machine ftp.bar.com login mybar password rosebud
macdef init
ascii
prompt
cd /pub/docs/mydocs
See "man ftp" for more information. This should be able to handle the
backslash problem you were having.
|
|
|
|
|