Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


Expand
titleSolution 1

pshell

login

sean

????

delegate

exit

pshell whoami


Exercise - script a task to download a file in your directory.

Expand
titleSolution 2

Create a plain text file script1.txt containing:

Code Block
cd Demo/sean
get testfile1


pshell -i script1.txt




Exercise - script a task that attempts to perform something that will fail (eg remove a directory that doesn't exist) and correctly report that the script encountered an error.

Expand
titleSolution 3


Run the following script if you have bash ... sorry Windows users (without WSL.)


Code Block
#!/bin/bash

pshell "rmdir /idontexist"

if [ $? == 0 ]; then
   echo "All good - proceed further!"
else
   echo "Operation failed!"
fi

Which produces:

Code Block
Error from server: The namespace '/idontexist' does not exist or is not accessible
Operation failed!


This would typically be a job script on (eg) Pawsey HPC - where you would be doing all such work in a Linux environment.

The idea is that if something in your data setup pipeline fails - don't waste any valuable cpu time on it.




Exercise - modify the script from the previous exercise to perform something that will succeed  (eg upload a file from your local desktop) and correctly report that the operation was successful.

Expand
#!/bin/bash

pshell "put testfile"

if [ $? == 0 ]; then
   echo "All good - proceed further!"
else
   echo "Operation failed!"
fi