Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to write a shell script over ssh via a bash prompt. The shell, however, insists on interpreting any variable I want to write instead of writing it directly to file. For example, cat <<EOF >\n'$command'EOF is simply written as '' to file. How do I get $command written instead? I've tried every practical method of escaping I can think of.

If it changes anything, I'm doing it over PHP using phpseclib.

share|improve this question
up vote 6 down vote accepted

Try quoting the first EOF, e.g.,

cat <<'EOF'

This is explained in the bash(1) man page, in the section, Here Documents.

share|improve this answer
I actually needed the INVERSE of this (had a script with "EOF", needed to handle variables) and this pointed me at it. Thanks! – Soulhuntre Dec 4 '12 at 7:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .