Perhaps have the shell script ask for the key, then store the key in a temp file and use openssl's -kfile option to find it. Hope your version of openssl supports -kfile.
I'd worry about security with this, but with a little care the security hole is perhaps smaller than you might think. (But do you trust your sysadmin and sudoers...?)
#!/bin/bash
INFILE=somefile
read -s -p "Enter key for $INFILE: " key
echo
# write the key to a temp file; use mktemp(1)
# for safer creation of a privately-owned file.
#
TMPKEY=$(mktemp -t) || exit 1
echo "$key" > "$TMPKEY"
# will remove the temp file on script exit
trap 'rm -f "$TMPKEY"' EXIT
# remove the key file a couple seconds after openssl runs
(sleep 2; rm -f "$TMPKEY") &
openssl enc -d -aes256 -in "$INFILE" -kfile "$TMPKEY" | less
[ -f "$TMPKEY" ] && rm -f "$TMPKEY"
trap - EXIT
# rest of script...
exit 0
$tmp_file=$(mktemp); openssl enc -d -in somefile > $tmp_file; less $tmp_file; rm $tmp_file
– Animalrsync
overssh
, and usually have no problems. When things do get mixed up, it seems to be a timing thing - it's not happened for a while, but as I recall, if rsync was slow at asking for a password, things went haywire. – Policewoman