Click to See Complete Forum and Search --> : Bash Script


MMA
05-06-2002, 12:58 PM
Can anyone help!. I really don't know why this is not working. I had used it before and it worked and after i reinstalled REDHAT7.2 it has not been working. Here is the script, i'm sure you'll know what it is suppose to do:


#! /bin/bash

rez=( "320x240" "1024x768" )
username="my user name"
password="my password"
ftpname=ftp://www.150m.com

for singlerez in ${rez[@]}; do
echo "__________________________________________________ ______"
echo "************************************************** ******"
echo "Renaming screenshot: MMA$singlerez"
mv -f MMA$singlerez.png "MMA"$singlerez"_old.png"
wait
echo "__________________________________________________ ______"
echo "************************************************** ******"
echo "Taking screenshot: "$singlerez
import -window root "MMA$singlerez.png" -geometry $singlerez
wait
echo "__________________________________________________ ______"
echo "************************************************** ******"
echo "Uploading screenshot: MMA$singlerez.png"
curl -T "MMA$singlerez.png" -u $username:$password $ftpname
wait
echo "__________________________________________________ ______"
echo "************************************************** ******"
echo "Finished: MMA"$singlerez".png"
echo "__________________________________________________ ______"
echo "************************************************** ******"
echo "Uploading screenshot: "MMA$singlerez_old.png"
curl -T "MMA$singlerez_old.png" -u $username:$password $ftpname
wait
echo "__________________________________________________ ______"
echo "************************************************** ******"
echo "Finished: MMA$singlerez_old.png"
echo "__________________________________________________ ______"
echo "************************************************** ******"
done
echo "__________________________________________________ ______"
echo "************************************************** ******"
echo "__________________________________________________ ______"
echo "************************************************** ******"
echo "__________________________________________________ ______"
echo "************************************************** ******"
echo "__________________________________________________ ______"
echo "EVERYTHING IS FINISHED!!!!!!!!!!!!!!!!!"
echo "__________________________________________________ ______"
echo "************************************************** ******"
echo "__________________________________________________ ______"
echo "************************************************** ******"
echo "__________________________________________________ ______"
echo "************************************************** ******"
echo "__________________________________________________ ______"

# End



And also if anyone can improve it, be my guest!!!.

ScRapZ_1
05-06-2002, 01:29 PM
What does it say when it doesnt work? Errors? My first guess would be, do you have curl installed? How far does it get before it doesnt work?

z0mbix
05-07-2002, 03:51 AM
Is ftp://www.150m.com a valid URL? And as ScRapZ_1 says, what are the errors?

[ 07 May 2002: Message edited by: cheeky_zombie ]

z0mbix
05-07-2002, 03:56 AM
and, did you ever see my message in your previous thread (http://www.linuxnewbie.org/cgi-bin/ubbcgi/ultimatebb.cgi?ubb=get_topic&f=3&t=006989)?

MMA
05-07-2002, 08:16 AM
Originally posted by cheeky_zombie:
<STRONG>Is ftp://www.150m.com a valid URL? And as ScRapZ_1 says, what are the errors?

[ 07 May 2002: Message edited by: cheeky_zombie ]</STRONG>

YES, it is a valid ftp site, i already used this before. I have curl installed, i tried the commands one by one in the console and it works. And here is the message that i get:

[MMA@localhost Desktop]$ bash mma
mma: line 52: unexpected EOF while looking for matching `"'
mma: line 56: syntax error: unexpected end of file
THNX :)

z0mbix
05-07-2002, 08:30 AM
How about taking all the crap out and trying it again:

[CODE]
#! /bin/bash
rez=( "320x240" "1024x768" )
username="my user name"
password="my password"
ftpname=ftp://www.150m.com/
for singlerez in ${rez[@]}; do
mv -f MMA$singlerez.png "MMA"$singlerez"_old.png"
wait
import -window root "MMA$singlerez.png" -geometry $singlerez
wait
curl -T "MMA$singlerez.png" -u $username:$password $ftpname
wait
curl -T "MMA$singlerez_old.png" -u $username:$password $ftpname
wait
done
# End
[CODE]

[ 07 May 2002: Message edited by: cheeky_zombie ]

MMA
05-07-2002, 05:03 PM
Originally posted by cheeky_zombie:
<STRONG>How about taking all the crap out and trying it again:

[CODE]
#! /bin/bash
rez=( "320x240" "1024x768" )
username="my user name"
password="my password"
ftpname=ftp://www.150m.com/
for singlerez in ${rez[@]}; do
mv -f MMA$singlerez.png "MMA"$singlerez"_old.png"
wait
import -window root "MMA$singlerez.png" -geometry $singlerez
wait
curl -T "MMA$singlerez.png" -u $username:$password $ftpname
wait
curl -T "MMA$singlerez_old.png" -u $username:$password $ftpname
wait
done
# End
[CODE]

[ 07 May 2002: Message edited by: cheeky_zombie ]</STRONG>

Thanks it worked. BUT i still don't know why it didn't work with all the echo "_________"
and echo "****************".