Unix Shell - Using FTP password beginning with a $

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > October 2004 > Using FTP password beginning with a $





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 Using FTP password beginning with a $
rsine

2004-09-28, 3:31 am

I was assigned an FTP password that begins with a "$". This seems to
be creating issues when I try to execute the following script:

ftp -nv ftp.site.com << EOF
user test $123abc
put test.txt
EOF

I can login to the site but the password is not recognized. How do I
need to change the script to pass a password beginning with a $?

-Thanks
Chris F.A. Johnson

2004-09-28, 3:31 am

On 2004-09-24, rsine wrote:
> I was assigned an FTP password that begins with a "$". This seems to
> be creating issues when I try to execute the following script:
>
> ftp -nv ftp.site.com << EOF
> user test $123abc
> put test.txt
> EOF
>
> I can login to the site but the password is not recognized. How do I
> need to change the script to pass a password beginning with a $?


Put the login information in your .netrc file, or escape the dollar
sign ( \$123abc ).

--
Chris F.A. Johnson http://cfaj.freeshell.org/shell
========================================
===========================
My code (if any) in this post is copyright 2004, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
Arjan Groenemeijer

2004-09-28, 3:31 am

rsine wrote:

> I was assigned an FTP password that begins with a "$". This seems to
> be creating issues when I try to execute the following script:
>
> ftp -nv ftp.site.com << EOF
> user test $123abc
> put test.txt
> EOF
>
> I can login to the site but the password is not recognized. How do I
> need to change the script to pass a password beginning with a $?
>
> -Thanks


Escape the $ with a backslash:

ftp -nv ftp.site.com << EOF
user test \$123abc
put test.txt
EOF


Arjan Groenemeijer
--
TIP: www.linuxlinks.com
Slackware (10) Current - Slackware User Since '96.
mail $(echo qnqiqmqdqrqaquqgq@qmqyqrqeqaqlqbqoqxq.qcqoqmq | sed 's/q//g')
Lew Pitcher

2004-09-28, 3:31 am

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

rsine wrote:
> I was assigned an FTP password that begins with a "$". This seems to
> be creating issues when I try to execute the following script:
>
> ftp -nv ftp.site.com << EOF
> user test $123abc
> put test.txt
> EOF
>
> I can login to the site but the password is not recognized. How do I
> need to change the script to pass a password beginning with a $?
>
> -Thanks


PASSWD='$123abc'
ftp -nv ftp.site.com << EOF
user test $PASSWD
put test.txt
EOF

- --

Lew Pitcher, IT Consultant, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFBVGkJagVFX4UWr64RAu9CAJ94hQmbz9kO
bI2IHpihgsGfZ4lAagCguo9B
7spmZCGNsfaF+uTuXcOndaU=
=WnKR
-----END PGP SIGNATURE-----
Alan Connor

2004-09-28, 3:31 am

On 24 Sep 2004 11:26:52 -0700, rsine <rsine@stationeryhouse.com>
wrote:


> I was assigned an FTP password that begins with a "$". This
> seems to be creating issues when I try to execute the following
> script:
>
> ftp -nv ftp.site.com << EOF user test $123abc put test.txt EOF
>
> I can login to the site but the password is not recognized.
> How do I need to change the script to pass a password beginning
> with a $?
>
> -Thanks


Try putting it in quotes or escaping it like so \$.


AC
Stachu 'Dozzie' K.

2004-09-28, 3:31 am

On 2004-09-24, rsine wrote:
> I was assigned an FTP password that begins with a "$". This seems to
> be creating issues when I try to execute the following script:
>
> ftp -nv ftp.site.com << EOF
> user test $123abc
> put test.txt
> EOF
>
> I can login to the site but the password is not recognized. How do I
> need to change the script to pass a password beginning with a $?


If you use bash or zsh you can try something like that:
#v+
ftp -nv ftplsite.com << 'EOF'
user test $123abc
put test.txt
EOF
#v-

I don't know if it works with other shells.

--
Stanislaw Klekot
Barry Margolin

2004-09-28, 3:31 am

In article <cj1qsk$c0f$1@news.dialog.net.pl>,
"Stachu 'Dozzie' K." <cut-to-last-hypen-dozzie@dynamit.im.pwr.wroc.pl>
wrote:

> On 2004-09-24, rsine wrote:
>
> If you use bash or zsh you can try something like that:
> #v+
> ftp -nv ftplsite.com << 'EOF'
> user test $123abc
> put test.txt
> EOF
> #v-
>
> I don't know if it works with other shells.


The rule that quoting the end marker prevents variable expansion in the
here-document was in Bourne shell, so it should work with pretty much
any shell. It even works in C shell, although it requires you to
include the quotes around the marker in the here-document as well:

cat <<'EOF'
$123abc
'EOF'

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Chris F.A. Johnson

2004-09-28, 3:32 am

On 2004-09-24, rsine wrote:
> I was assigned an FTP password that begins with a "$". This seems to
> be creating issues when I try to execute the following script:
>
> ftp -nv ftp.site.com << EOF
> user test $123abc
> put test.txt
> EOF
>
> I can login to the site but the password is not recognized. How do I
> need to change the script to pass a password beginning with a $?


Put the login information in your .netrc file, or escape the dollar
sign ( \$123abc ).

--
Chris F.A. Johnson http://cfaj.freeshell.org/shell
========================================
===========================
My code (if any) in this post is copyright 2004, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
rsine

2004-09-28, 8:28 am

Barry Margolin <barmar@alum.mit.edu> wrote in message news:<barmar-C5B0EE.20131824092004@comcast.dca.giganews.com>...
> In article <cj1qsk$c0f$1@news.dialog.net.pl>,
> "Stachu 'Dozzie' K." <cut-to-last-hypen-dozzie@dynamit.im.pwr.wroc.pl>
> wrote:
>
>
> The rule that quoting the end marker prevents variable expansion in the
> here-document was in Bourne shell, so it should work with pretty much
> any shell. It even works in C shell, although it requires you to
> include the quotes around the marker in the here-document as well:
>
> cat <<'EOF'
> $123abc
> 'EOF'



I tried each suggestion and still am not having any success with the
password. Here is a sample of what I get from the FTP server when
running my script:

Connected to ftp.site.com.
220 osiris Microsoft FTP Service (Version 5.0).
331 Password required for test.
530 User test cannot log in.
Login failed.
530 Please login with USER and PASS.
200 PORT command successful.
530 Please login with USER and PASS.
221

Is there anything else I can try?
Kenny McCormack

2004-09-28, 8:28 am

In article <bc91bd3a.0409280504.333fbb0c@posting.google.com>,
rsine <rsine@stationeryhouse.com> wrote:
....

ITYM: I cannot login to the site because the password is not recognized.
[vbcol=seagreen]
>I tried each suggestion and still am not having any success with the
>password. Here is a sample of what I get from the FTP server when
>running my script:
>
>Connected to ftp.site.com.
>220 osiris Microsoft FTP Service (Version 5.0).
>331 Password required for test.
>530 User test cannot log in.
>Login failed.
>530 Please login with USER and PASS.
>200 PORT command successful.
>530 Please login with USER and PASS.
>221
>
>Is there anything else I can try?


Well, the simple "cat test" will show if there is any kind of quoting
issue. I assume that the following works as expected:

sh
$ cat << 'X'
user test $abc1234
X
$

Assuming that works, then the "issue" must be somewhere else.

1) Just for the record, can you login to this account manually?
(Maybe MS servers have a problem with PWs that start with $...)

2) You might want to consider a different FTP client. I never liked the
"ftp << EOF" kinda thing much anyway. Maybe try ncftp.

rsine

2004-10-02, 9:12 pm

Barry Margolin <barmar@alum.mit.edu> wrote in message news:<barmar-C5B0EE.20131824092004@comcast.dca.giganews.com>...
> In article <cj1qsk$c0f$1@news.dialog.net.pl>,
> "Stachu 'Dozzie' K." <cut-to-last-hypen-dozzie@dynamit.im.pwr.wroc.pl>
> wrote:
>
>
> The rule that quoting the end marker prevents variable expansion in the
> here-document was in Bourne shell, so it should work with pretty much
> any shell. It even works in C shell, although it requires you to
> include the quotes around the marker in the here-document as well:
>
> cat <<'EOF'
> $123abc
> 'EOF'



I tried each suggestion and still am not having any success with the
password. Here is a sample of what I get from the FTP server when
running my script:

Connected to ftp.site.com.
220 osiris Microsoft FTP Service (Version 5.0).
331 Password required for test.
530 User test cannot log in.
Login failed.
530 Please login with USER and PASS.
200 PORT command successful.
530 Please login with USER and PASS.
221

Is there anything else I can try?
Kenny McCormack

2004-10-02, 9:12 pm

In article <bc91bd3a.0409280504.333fbb0c@posting.google.com>,
rsine <rsine@stationeryhouse.com> wrote:
....

ITYM: I cannot login to the site because the password is not recognized.
[vbcol=seagreen]
>I tried each suggestion and still am not having any success with the
>password. Here is a sample of what I get from the FTP server when
>running my script:
>
>Connected to ftp.site.com.
>220 osiris Microsoft FTP Service (Version 5.0).
>331 Password required for test.
>530 User test cannot log in.
>Login failed.
>530 Please login with USER and PASS.
>200 PORT command successful.
>530 Please login with USER and PASS.
>221
>
>Is there anything else I can try?


Well, the simple "cat test" will show if there is any kind of quoting
issue. I assume that the following works as expected:

sh
$ cat << 'X'
user test $abc1234
X
$

Assuming that works, then the "issue" must be somewhere else.

1) Just for the record, can you login to this account manually?
(Maybe MS servers have a problem with PWs that start with $...)

2) You might want to consider a different FTP client. I never liked the
"ftp << EOF" kinda thing much anyway. Maybe try ncftp.

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com