Skip to content
Snippets Groups Projects
Commit 9630e173 authored by Trond Aasan's avatar Trond Aasan
Browse files

Simplify upload script

Fixes shellcheck errors
parent a8e36bf7
No related branches found
No related tags found
1 merge request!3Add shell script linting
Pipeline #56509 passed
#!/bin/bash
# Upload script
COUNT=0
# Exit on error
set -e
rm sftp_batch.tmp
# Find files and write batchfile to be passed to sftp
for output in $(ls *.xml -1)
do
COUNT=1
printf "put -P \"$output\"\n" >> sftp_batch.tmp
done
# Upload script
# Exit if nothing to upload
if [[ $COUNT -eq 0 ]]; then
#printf "$0: No files to upload" >$2
exit 1
fi
# Output which commands we will be running
#printf "Connecting with sftp and executing following commands:\n"
#printf "$(<sftp_batch.tmp)"
sftp -b sftp_batch.tmp cristin-export@norzola.uio.no:cristin/ || exit 1
#scp $output cristin-export@norzola.uio.no:cristin/ || exit
#Archive transferred files
for output in $(ls *.xml -1)
do
mv $output archive/
done
rm sftp_batch.tmp
printf 'put -P *.xml' | sftp -b - cristin-export@norzola.uio.no:cristin/
mv ./*.xml archive/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment