From owner-freebsd-questions@FreeBSD.ORG Tue Dec 16 10:59:12 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 421B116A4CE for ; Tue, 16 Dec 2003 10:59:12 -0800 (PST) Received: from mail.tsgincorporated.com (mail.tsgincorporated.com [67.66.242.7]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4507043D36 for ; Tue, 16 Dec 2003 10:59:09 -0800 (PST) (envelope-from micheal@tsgincorporated.com) Received: (from root@localhost) by mail.tsgincorporated.com (8.12.10/8.12.8) id hBGIx9WG096948 for questions@freebsd.org; Tue, 16 Dec 2003 12:59:09 -0600 (CST) (envelope-from micheal@tsgincorporated.com) Received: from micheal (micheal.tsgincorporated.com [67.66.242.77]) hBGIx5BI096936 for ; Tue, 16 Dec 2003 12:59:05 -0600 (CST) (envelope-from micheal@tsgincorporated.com) Message-ID: <061701c3c406$ad39cc80$4df24243@tsgincorporated.com> From: "Micheal Patterson" To: References: <200312161838.hBGIcTLe005322@lv.raad.tartu.ee> Date: Tue, 16 Dec 2003 12:59:03 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by AMaViS 0.3.12 Subject: Re: fetch / wget problem X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2003 18:59:12 -0000 ----- Original Message ----- From: "Toomas Aas" To: Sent: Tuesday, December 16, 2003 12:38 PM Subject: fetch / wget problem > Hi! > > I'm trying to write a script which gets a file from remote FTP server. > > The FTP username contains dots and this cannot be changed. > > There are two firewalls involved, one running on the same server where > I'm doing this (ipfilter, using ipnat ftp proxy) and one between this > server and the FTP server. The FTP server itself is in internal network > using RFC1918 addresses and a port in firewall is being forwarded to > this server. > > I think that firewalls are configured correctly, because I can > successfully get the file manually, using the 'ftp' command. > > However, when I try this command: > > fetch ftp://user.name:password@server.mydomain.com/directory/file.ext > > I get an error message: > fetch: ftp://user.name:password@server.mydomain.com/directory/file.ext: > Host not found. > > I suspect that fetch, seeing a dot in username, attempts to 'resolve' > the entire URL, instead of just the part after @. Is there a known > workaround to this? > > I also tried wget, which succeeds to connect, but then, no matter what > I do, insists on using passive mode. > > wget ftp://user.name:password@server.mydomain.com/directory/file.ext > Connecting to server.mydomain.com[12.34.56.78]:2100... connected. > Logging in as user.name ... Logged in! > ==> SYST ... done. ==> PWD ... done. > ==> TYPE I ... done. ==> CWD /directory ... done. > ==> PASV ... > and then the process just hangs. > > I suspect it would work if I could somehow tell wget to NOT use passive > mode. I initially had FTP_PASSIVE_MODE environment variable set, but > removing this didn't affect wget's behaviour. > > Any ideas? > -- > Toomas Aas | toomas.aas@raad.tartu.ee | http://www.raad.tartu.ee/~toomas/ > * RUNTIME ERROR 6D at 417A:32CF : Incompetent user > You may be able to do this with a .netrc in the user folder that's running the script. In .netrc, you'll have: machine login password Then you can script it with the exact commands that you'd use to get the file if you did it manually. For example, if you wanted /etc/test.sh and you wanted to store it in /root/down and the remote site was ftp.foo.com you'd do: Contents of .netrc --- machine ftp.foo.com login joe.user pass password --- Then, in your script, let's say autofetch.sh you'd have: #!/bin/sh ftp << EOF open ftp.foo.com cd /etc/ lcd /root/down ascii get test.sh bye EOF ----------- Now, you've got a scripted ftp session from within FreeBSD. As long as the servernames in the script and .netrc match, ftp will use the info from .netrc to make the connection. Of course, you'd want to make certain that the .netrc file is NOT world readable. Perhaps not even group readable if there are other users of the system. Hope it helps. -- Micheal Patterson TSG Network Administration 405-917-0600 Confidentiality Notice: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.