Versions Compared

Key

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

...

Code Block
languagebash
themeMidnight
#!/bin/bash

###############################################################################
#
# You must include the following at the top of you script for the script
# upload command
#
###############################################################################
SCRIPTPATH="$(
    cd "$(dirname "$0")"
    pwd -P
)"
SCRIPTNAME="$(echo $0 | awk -F './' '{print $2}')"
script="$SCRIPTPATH/$SCRIPTNAME"

# These are some base commands to further simplify use.
heading='la_page_entry.sh -n "$notebook" -f "$lafolder" -p "$lapage" -t "heading" -e'
plaintext='la_page_entry.sh -n "$notebook" -f "$lafolder" -p "$lapage" -t "plain text entry" -e'
scriptenvupload='laout.sh -n "$notebook" -f "$lafolder" -p "$lapage" -s "$script"'
fileuploadtop='la_upload.sh -n "$notebook" -p "$lapage" -a "$filetoupload" file'
fileuploadsub='la_upload.sh -n "$notebook" -f "$lafolder" -p "$lapage" -a "$filetoupload" file'
diruploadtop='la_upload.sh -n "$notebook" -d "$dirtoupload" directory'
diruploadtofolder='la_upload.sh -n "$notebook" -f "$lafolder" -d "$dirtoupload" directory'
filesumtop='la_upload.sh -n "$notebook" -p "$lapage" -a "$filetosum" lasum_file'
filesumsub='la_upload.sh -n "$notebook" -f "$lafolder" -p "$lapage" -a "$filetosum" lasum_file'
dirsumtop='la_upload.sh -n "$notebook" -p "$lapage" -d "$dirtosum" lasum_directory'
dirsumsub='la_upload.sh -n "$notebook" -f "$lafolder" -p "$lapage" -d "$dirtosum" lasum_directory'

###############################################################################
#
# The following are optional variables and are used here to demonstrate
# simplifying multiple notebook entries.
#
###############################################################################
notebook="Trent's second notebook"
folderlafolder="My tests"
pagelapage="Uploaded files"
homedir=$HOME
filetoupload="$homedir/Desktop/Test top/test1.txt"
dirtoupload="$homedir/Desktop/Test top"
filetosum="$homedir/Desktop/Test top/test1.txt"
dirtosum="$homedir/Desktop/Test top"

###############################################################################
#
# Some examples for adding data to LabArchives
#
# Where the variables $page$lapage and $folder$lafolder are used there must already exist
# a corresponding page or folder in your LabArchives notebook
#
###############################################################################

# Add heading
eval $(echo la_page_entry.sh -n \"$notebook\" -f \"$folder\" -p \"$page\" -t \"heading\" -e \"$heading \"Run 1\")

# Add entry text
eval $(echo la_page_entry.sh -n \"$notebook\" -f \"$folder\" -p \"$page\" -t \"plain text entry\" -e \"$plaintext \"We used the white mice for this experiment.\")

# Upload script and environment info
eval $(echo laout.sh -n \"$notebook\" -f \"$folder\" -p \"$page\" -s \"$script\"$scriptenvupload)

# File uploads will upload duplicate files
# Upload a file to top level
eval $(echo la_upload.sh -n \"$notebook\" -p \"$page\" -a \"$homedir/Desktop/Test top/test1.txt\" file$fileuploadtop)

# Upload a file to a specific LA folder
eval $(echo la_upload.sh -n \"$notebook\" -f \"$folder\" -p \"$page\" -a \"$homedir/Desktop/Test top/test1.txt\" file$fileuploadsub)

# Directory uploads will only upload files once.  If run again will upload new files only.  It won't delete files.
# Upload a directory to top level
eval $(echo la_upload.sh -n \"$notebook\" -d \"$homedir/Desktop/Test top\" directory$diruploadtop)

# Upload a directory to specific LA folder
eval $(echo la_upload.sh -n \"$notebook\" -f \"$folder\" -d \"$homedir/Desktop/Test top\" directory$diruploadtofolder)

# Add file name with shasum to page
eval $(echo la_upload.sh -n \"$notebook\" -p \"$page\" -a \"$homedir/Desktop/Test top/test1.txt\" lasum_file$filesumtop)

# Add file name with shasum to page in a specific LA folder
eval $(echo la_upload.sh -n \"$notebook\" -f \"$folder\" -p \"$page\" -a \"$homedir/Desktop/Test top/test1.txt\" lasum_file$filesumsub)

# Add all file names with shasums in a directory in an attachment to a page at the top level in athe specific foldernotebook
eval $(echo la_upload.sh -n \"$notebook\" -f \"$folder\" -p \"$page\" -d \"$homedir/Desktop/Test top\" lasum_directory$dirsumtop)

# Add all file names with shasums in a directory in an attachment to a page atin thea topspecific level in the notebook
folder
eval $(echo la_upload.sh -n \"$notebook\" -p \"$page\" -d \"$homedir/Desktop/Test top\" lasum_directory$dirsumsub)