Hi everybody, i need to modify some scripts to repeat the commands in them until a variable returns a proper value. I need it to add some redundancy to some scripts i use to upload files to a remote server.
This is an example of a portion of those scripts:
Code:
################## site UPLOAD ##################
site_login=$(curl -c $site_cookie -L -F user=$site_user -F pass=$site_password -F submit=Login http://site.com/login.html)
site_page=$(curl -b $site_cookie -c $site_cookie http://site.com)
site_action=$(echo "$site_page" | grep "site.com/upload.php" | cut -f2 -d"\"")
site_progress_key=$(echo "$site_page" | grep "progress_key" | grep -o "value=\"[0-9a-zA-Z]*\"" | cut -f2 -d"\"")
site_usergroup_key=$(echo "$site_page" | grep "usergroup_key" | grep -o "value=\"[0-9a-zA-Z]*\"" | cut -f2 -d"\"")
site_UPLOAD_IDENTIFIER=$(echo "$site_page" | grep "UPLOAD_IDENTIFIER" | grep -o "value=\"[0-9a-zA-Z]*\"" | cut -f2 -d"\"")
post=$(echo "-F APC_UPLOAD_PROGRESS=$site_progress_key -F APC_UPLOAD_USERGROUP=$site_usergroup_key -F UPLOAD_IDENTIFIER=$site_UPLOAD_IDENTIFIER")
results_site=$(curl -L -b $site_cookie $post $site_action -F file[]='' -F file[1]=@$scenes_directory/$f -F submit=Upload)
site_link=$(echo "$results_site" | grep -o "http://site.com/files\/[a-zA-Z./0-9_-]*" | sed q)
Now i need to verify if the variable site_link has a proper value (it should match the regex
http://site.com/files\/[a-zA-Z./0-9_-]*), and if it hasnt, reapeat the previous commands to retry the upload UNTIL a proper link is set.
Any idea on how to do it?
I guess a WHILE is needed, but i never used it, so i'm not sure on where to place it or how to write it.
Thanks.