Download the following file to your PC, then upload it to remote.it:
The r3_header line is a special line that starts with the hash/pound symbol #. This is interpreted by the shell processor as a comment. The remot3.it Bulk Scripting server reads this line, if present, when you upload the file, and keeps track of parameters that will be asked for whenever the script is executed.
The "Send-File-Sample.sh" script uses the "-f" parameter in an r3_header comment line near the top of the file, as shown:
# r3_header, -f (Select File|.)
The information in parentheses should be interpreted as:
( Prompt string | file spec )
- Prompt string = "Quotes enclosed string to display when the dialog is shown"
- File spec = which files to show in the selection list.
- . => *.* (all files)
- .zip => *.zip
The given example shows the following dialog when you run "Execute Script".
Note that you can also enter a file URL here. This will be used later on in the script.
Look for the following section near the end of the script.
################################################
# parse the flag options (and their arguments) #
################################################
while getopts f:m:p:l:s: OPT; do
case "$OPT" in
f)
# get file, this should be in the format "file -O output file"
filename=$(echo $OPTARG | awk '{ print $3 }')
newfilename=$(echo $filename | sed s/%20/""/g)
Status_A "Downloading $newfilename..."
Log "Downloading $newfilename..."
Task_Update "Downloading $newfilename..."
Download_With_Retry "$OPTARG" "$LIMIT_SPEED"
Log "newfilename: $newfilename..."
mv "$filename" "$newfilename"
Task_Update "Downloaded $newfilename"
;;
esac
done
In this script, the following line removes any spaces in the file name.
newfilename=$(echo $filename | sed s/%20/""/g)
At the end of the "getopts" loop, the file will have been downloaded into the /tmp folder. At this point, you can do anything you want with the file. This example just gets the file size in bytes and the MD5 checksum and reports those values back to the Status cells.