I want to download file from server using FTP.
Here's my script code. (myscript.sh)
ftp -n $1 << END
user $2 $3
After writing script and run, It does not working.
sh myscript.sh 111.222.333.444 testuser test /myfolder/src/data/ DATA20140419.txt
shell display this message : usage lcd local-directory
What's the problem in my script code?
Best How To :
I solved this problem.
The reason is, encoding.
I wrote script code using windows, run in unix.
I missed that difference of "ENTER".
UNIX's enter is \n
but, Windows enter is \r\n
so, Without encoding script code, error must be occured.
Most of windows editer supply encoding option. (UNIX, DOS, WINDOWS style.)
If you use unix editor(ex, vi) you don't need to encoding.
If you didn't set remote directory(cd) or local directory(lcd), the source and destnation is default folder.
END, EOF don't effect script code. you can use any string.
To run shell script, you must use "sh" keyword. "./" can't run shell script.