Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I am trying to make an automatic installer which downloads file from ftp and installs it on system .

Host = "zzz " 
USER= "ss"
PASSWD = " xxXX"
FILE = " *.tar"
ftp $HOST << EOF
user $USER
passwd $PASSWD
---#to save in folder /tmp
cd /tmp
mget $(ls -t | head -1) --# to get last file

Is this code is proper? And how will I know that the download has finished? Should I make any code changes for that? Because as soon as its finished downloading I have to install it using sudo dpkg. How to use this command in my existing code which I have written above?

share|improve this question

closed as unclear what you're asking by Lucio, Alvar, Eric Carvalho, karel, Avinash Raj Dec 23 '13 at 6:38

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

You're asking if this code is proper--have you tried running it yet, to see if/how it works? – Eliah Kagan Jan 7 '13 at 7:12
error:File format not recognized:,,,,collect2: id returned 1 exit state – sooraj Jan 7 '13 at 7:16
do you have control over the ftp server? If you do, maybe it would be nice to always have a symbolic link that always pointing to the latest version (myapp-latest.deb), and then make your script download that. – elias Jan 8 '13 at 18:56

1 Answer 1

For this kind of script, you would better use Expect than hand crafted code.

share|improve this answer
Why isn't shell-script a fine choice in this case? I know expect is good for interactive sessions, but the interactive part is quite small in this case (password can probably be passed in the url), a shell script would be fine. – elias Jan 8 '13 at 18:53
You're right, it may be a bit overkill. Also , there is wget, which can download from ftp and have login and pass on command line. AFAIK its available with default Unbuntu install. – Arcadien Jan 9 '13 at 15:34
exactly, that's what I would try to do in a case like this. – elias Jan 9 '13 at 16:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.