bash, echo or cat both a system variable and the contents of a text file onto 1 line

Using bash to pull data out of a file and mix this data with some variables and then echo the results onto 1 line. I have most of this figured out. The output of the echo should look like this
ftp://joe:hippo@myftpsite.com
Where joe and hippo is actually data within 2 different files.
Here is what I am actually getting
click here ----->   ftp://user.txt:password.txt@myftpsite.com   <----- click here

#start of script
#-----------------------------------
FTP="ftp://"
USER="user.txt"                                  ##This is a file with the user name in it
COLON=":"
PASSWORD="password.txt"              ##This is a file with the password in it
AT="@"
SITE="myftpsite.com"

echo "click here ----->   $FTP$USER$COLON$PASSWORD$AT$SITE   <----- click here"
#-------------------------------------
#end of script
LVL 1
DMS-XAsked:
Who is Participating?
 
wesly_chenCommented:
Hi DMS-X,

   You might want to change two lines:
USER="user.txt"      ===> USER=`cat user.txt`
PASSWORD="password.txt"   ===> PASSWORD=`cat password.txt`

  Use "back quote" to execute the comand and pass the result to the variable.

Regards,

Wesly
0
 
DMS-XAuthor Commented:
Ok lets make this easier. Lets say that I would like to have $TIME be the sysem variable set by executing the command date?
0
 
DMS-XAuthor Commented:
Or better yet how to get and set a variable based on the output of a command within the script it is being run?
0
 
owensleftfootCommented:
" Or better yet how to get and set a variable based on the output of a command within the script it is being run?"


Use backticks.

MYVAR = `ls -a` would assign the output of ls -a to MYVAR. (Well it does in perl anyway - Im assuming it does in shell as well. Its worth a try.)
0
 
DMS-XAuthor Commented:
That was it. I did try the back quote thing a long time ago but I was using ' instead of ` they look the same gosh darn it. I could have saved myself 500 points and alot of time : )

Thank you sir wesley!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.