Skip to content

Instantly share code, notes, and snippets.

@j1ah0ng
Created March 21, 2020 19:35
Show Gist options
  • Save j1ah0ng/b2554cd1c465b11d63bcc31ba54ea0de to your computer and use it in GitHub Desktop.
Save j1ah0ng/b2554cd1c465b11d63bcc31ba54ea0de to your computer and use it in GitHub Desktop.
syncing from servers
#!/usr/bin/env bash
echo "Please make sure you are running this script from the directory\
you want to download your PA to."
echo -n "The current directory is "
echo -n $(pwd)
echo -n " and contains "
echo -n $(ls -l | wc -L)
echo " files."
echo
echo "If this not correct, ctrl+c now and switch to the correct directory,\
and re-run again."
echo -n "Enter the current hw number (ex. hw9, hw10): "
read hw
echo -n "Enter your cs12wi20xx account without the @ieng6.ucsd.edu suffix: "
read acct
echo -n "This script assumes your remote files are located at\
[email protected]:~/$hw. Is this correct? (Y)es or (N)o: "
read resp
if [[ "$resp" == "n" ]]; then
echo "Please enter the relative path your files are stored at, starting at\
~/. For instance, if your $hw folder is located in ~/homeworks/$hw, please\
enter \"homeworks/$hw\"."
echo -n "Enter the relative path: "
read path
else
path = $hw
fi
echo "When prompted, please enter the password for $acct."
rsync -r [email protected]:~/$path ./
if [[ $? == 0 ]]; then
echo "Files were successfully saved to $(pwd) "
else echo "Failed. Try again."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment