how to convert this script in command line?

im trying to use this shellscript in one command line, but isnt working.

shellscript:

	SERVER=ftp.site.com
	USER=Foo
	PASSW=3122

	ftp -v -n $SERVER <<END_OF_SESSION
	user $USER $PASSW
	$FILETYPE
	lcd /home/foo/mywebsite
	mput *
	mput *.*
	bye
	END_OF_SESSION

Im trying a lot of commands like this below, but none works...

# server=ftp.site.com && user=Foo && passw=3122 && ftp -v -n $server << $(echo -e  "EOT\nuser $user $passw\nascii\n$FILETYPE\nlcd /home/foo/mywebsite\nmput *\nmput *.*\nbye\nEOT\n")

Ok, do you mind posting the error messages you get? Use code tags if you post them, thanks.

this command dont finish, keeps w/ a ">" waiting to finish the command:

# server=ftp.site.com && user=Foo && passw=3122 && ftp -v -n $server << $(echo -e  "EOT\nuser $user $passw\nascii\n$FILETYPE\nlcd /home/foo/mywebsite\nmput *\nmput *.*\nbye\nEOT\n")
>

trying other commands i got this:

# server=ftp.site.com && user=Foo && passw=3122 && ftp -v -n $server '<< EOT user $user $passw $FILETYPE lcd /home/foo/mywebsite mput * mput *.* bye EOT' echo ok
usage: -n host-name [port]
ftp> 

---------- Post updated at 12:43 PM ---------- Previous update was at 12:14 PM ----------

One more try:

doing this:

echo -e "EOT\n&& user $user $passw\nascii\n$FILETYPE\nlcd /home/foo/mywebsite\nmput *\nmput *.*\nbye\nEOT"

results in this:

EOT
&& user Foo 3122
ascii

lcd /home/foo/mywebsite
mput *
mput *.*
bye
EOT

but when doing this:

server=ftp.site.com && user=Foo && passw=3122 && ftp -v -n $server << echo -e "EOT\n&& user $user $passw\nascii\n$FILETYPE\nlcd /home/foo/mywebsite\nmput *\nmput *.*\nbye\nEOT"

results this:

>

---------- Post updated at 12:46 PM ---------- Previous update was at 12:43 PM ----------

ho, just ignore the "&&" after EOT in last post, just wrong paste here

Your script in post #1 has a layout problem.
The terminating string END_OF_SESSION MUST start in column one. i.e. Don't indent that line.
Also, you don't set a value for $FILETYPE . Presumably it would be ascii rather than binary .

The long command version does not produce valid ftp syntax.
The "EOT" and "&&" are totally surplus and should not be there.

The server=".... commands..." construct is faulty.
It's just a string assignment. It never executes any commands.
The executable bit needs backticks:
server=`".... commands..."`
Both the backticks and the double quotes are needed. It is well worth reading up on the various quote characters until you understand them. Remember that within single quotes no variables are expanded at all.

The server= version of your script does not set the file type (ascii/binary). This will cause problems with your filenames (because they are not .txt) unless you set it correctly.

When posting Shell Scripting problems, please always post what Operating System and version you are running and what Shell you are using.
There may be more modern Posix syntax for executing commands in a string assignment depending on what Shell you have.

sorry, i cant understand how to solve the problem.

Lets make more simple: forget about the variables, this script works:

#!/bin/bash
ftp -v -n ftp.site.com <<END_OF_SESSION
user Foo 3122
ascii
lcd /home/foo/mywebsite
mput *
mput *.*
bye
END_OF_SESSION

What i need is a way to conect to a ftp account and send some files automatically.
Now how this can be done in command line? I need to reproduce this in a command line and then put inside a system() to execute in a c program running ubuntu 12.04

Try creating and testing a script, then executing that script from the C Programming Language system() call.
It will drive you nuts trying to get a one-liner to work in this situation.

Off topic.
Why?

mput *
mput *.*

If the source system is a unix system, the MSDOS 8.3 file naming convention is irrelevant. The mput * should be sufficient.

the script already exist:

ftp -v -n ftp.site.com <<END_OF_SESSION
user Foo 3122
ascii
lcd /home/foo/mywebsite
mput *
mput *.*
bye
END_OF_SESSION

The problem is i cant left open the information about server name, login and password to everyone see it. That's why i need to convert this command in one terminal command line.

yeah, this script was originally for DOS, dont really need the second line.