A Scripting Example
The following bash script demonstrates the use of
the techniques described on the previous pages in a single example.
To test it, copy the text and save it to a file named "test.sh",
then issue the Bash command source test.sh
.
#!/bin/bash
# Define variables for the endpoints we are using
gte1=ddb59aef-6d04-11e5-ba46-22000b92c6ec
gte2=ddb59af0-6d04-11e5-ba46-22000b92c6ec
# Transfer some files without email notifications and remember the task ID.
id=$( {
echo "/share/godata/file1.txt file1.txt"
echo "/share/godata/file2.txt file2.txt"
echo "/share/godata/file3.txt file3.txt"
} | globus transfer --notify off --jq "task_id" --format=UNIX --batch - $gte1 $gte2)
# Wait until the transfer is complete before continuing.
globus task wait $id
# Get the status value for the transfer operation and see if it succeeded.
stat=$(globus task show --jq "status" --format=UNIX $id)
if [ $stat != "SUCCEEDED" ]; then
echo "Transfer failed!"
else
echo "Transfer succeeded!"
fi