Hello, On Fri, 06 Feb 2009, David C. Rankin wrote:
David Haller wrote:
TPHRASE=somekey openssl genrsa -passout stdin -des3 -out server.key 1024 <<'GENPSK' $TPHRASE GENPSK
Dave,
You also single-quoted the start-tag, why?
*Oops!* Sorry. That's actually wrong in this case, as you want $TPHRASE expanded. Generally though, you should quote the tag just like a variable to keep from expansion. ==== man bash / Here documents section ==== <<[-]word here-document delimiter [..] If any characters in word are quoted, the delimiter is the result of quote removal on word, and the lines in the here-document are not expanded. If word is unquoted, all lines of the here-document are subjected to parameter expansion, command substitution, and arithmetic expansion. ==== Usually, you don't want expansions/substitutions in your here-documents, which is why I tend to quote the "word". And only conciously choose not to quote it, if I actually want expansion/substitution. For clarification: $ echo $TPHRASE somekey $ cat <<EOF
$TPHRASE EOF somekey $ cat <<"EOF" $TPHRASE EOF $TPHRASE $ cat <<'EOF' $TPHRASE EOF $TPHRASE $
Without the quotes, you need to escape ``, $(), $, etc. if you don't want them expanded. Using a quoted word is esp. useful if you want to pass on "shellscripts" via ssh -- unless you want e.g. some variables expanded. But that can be amended by using a combination of here-documents and echos "gathered together" by braces: { cat <<'PART_OF_SCRIPT' unexpanded $stuff and remotely run $(command) and an remotely expanded $variable. PART_OF_SCRIPT echo "$foo" cat <<PART_OF_SCRIPT expanded $stuff and run $(command generating stuff) and with an escaped and thus unexpanded "\$variable". Correctly quoting "'stuff'" inside is much easier than inside an echo or somesuch. PART_OF_SCRIPT } | ssh localhost cat The output by cat (via ssh) shows what the remote shell would be fed, if you replace the variables / commands in above sample by more meaningful things and 'cat' by 'bash' (or nothing if you want the remote default-shell of your remote user). Comes in quite handy at times, that does ;) -dnh -- The two most common things in the universe are hydrogen and stupidity. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org