kuldietercastel Mar 2nd, 2013 23 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- # retrieveHosts.sh
- # Available host file retrieving script
- # Description:
- # This script tries retrieving the list with available hosts from different hosts.
- # If succesfull the script will place the host.txt file at ~/recieved/
- # This script needs hostsToTxt.sh to be located at ~/scripts/ in order to function
- # This scripts supposes you are using an ssh-agent
- # If not this might also work but you will be typing your password a lot.
- # Easily setting up an ssh-agent can be done with my other script init_ssh-agent.sh.
- # Version: 1.0
- # Author: Dieter Castel
- # License: Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
- # See: http://creativecommons.org/licenses/by-nc-sa/3.0/ for more info.
- # Variables:
- # Place of the hostsToTxt.sh script. You can edit it if you want to move the script.
- # Output directory of the script.
- # List of the hosts that will be tried. You can expand this if you want more redundancy.
- possiblehosts=(ham genk herent mol zwalm)
- # Boolean that tells the script if it failed all the hosts.
- # Make the recieved directory.
- mkdir $outputdir
- # Iterate over all the possible hosts.
- for currentHost in $possiblehosts;
- echo "Will try ssh/scp with login $USER @ $currentHost"
- # Try to run the hostToTxt script on the currentHost.
- if ssh "$USER"@"$currentHost".cs.kotnet.kuleuven.be 'bash -s' < "$scriptpath";
- # If succesfull transfer the file from the host to the current machine.
- if scp "$USER"@"$currentHost".cs.kotnet.kuleuven.be:/home/"$USER"/toSend/hosts.txt "$outputdir";
- # If the transfer succeeds the script succeeds and we break out of the for loop.
- echo "hosts.txt succesfully transferd from $currentHost to $outputdir"
- echo "$currentHost failed to transfer the file";
- echo "$currentHost failed";
- # Report failure
- if $failure; then
- echo "Every try failed";
RAW Paste Data