Skip to content

Instantly share code, notes, and snippets.

@thomasp11
Created February 1, 2018 18:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasp11/fa7b6d1ef80bfbb0d4dcb28e9bce94af to your computer and use it in GitHub Desktop.
Save thomasp11/fa7b6d1ef80bfbb0d4dcb28e9bce94af to your computer and use it in GitHub Desktop.
#!/bin/bash
cloudshark_url="https://www.cloudshark.org"
api_token=${CLOUDSHARK_API}
filename=${1}
echo "curl -s -F file="@${filename}" ${cloudshark_url}/api/v1/${api_token}/upload"
response=$(curl -s -F file="@${filename}" ${cloudshark_url}/api/v1/${api_token}/upload)
json_id=$(echo $response | python -m json.tool | grep id)
if [ "$json_id" != "" ]; then
# find the CloudShark ID for this session
id=`echo $json_id | sed 's/:/ /1' | awk -F" " '{ print $2 }'| sed 's/\"//g'`
# show a URL using the capture session in CloudShark
echo "A new CloudShark session has been created at:"
echo "${cloudshark_url}/captures/$id"
else
echo "Could not upload capture to CloudShark:"
echo $response | python -m json.tool
fi
@thomasp11
Copy link
Author

CLOUDSHARK_API will need to be defined somewhere as your CloudShark API token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment