Hello Lee and Donovan.

Thank you for your information.

I tried the following

role :server, "user@server"

task :heredoctest, :roles => :server do
  command =  %Q{
     cat<<EOS|wc -l
       foo
       foo
       foo
EOS
  }
  run command

end

But execution failed.
The execution log is the following.

% cap heredoctest
  * executing `heredoctest'
  * executing "cat<<EOS|wc -l\\\n       foo\\\n       foo\\\n       foo
\\\nEOS"
    servers: ["server"]
    [user@server] executing command
*** [err :: user@server] sh: line 4: warning: here-document at line 4
delimited by end-of-file (wanted `EOS')
*** [err :: user@server] wc:
*** [err :: user@server] foo
*** [err :: user@server] : No such file or directory
*** [err :: user@server]
*** [err :: user@server] wc:
*** [err :: user@server] foo
*** [err :: user@server] : No such file or directory
*** [err :: user@server]
*** [err :: user@server] wc:
*** [err :: user@server] fooEOS
*** [err :: user@server] : No such file or directory
*** [err :: user@server]
 ** [out :: user@server] 0 total
    command finished in 54ms
failed: "sh -c 'cat<<EOS|wc -l\\\n       foo\\\n       foo\\\n
foo\\\nEOS'" on user@server

Sincerely.

--
Hiroyuki Sato


On 11月14日, 午前10:56, Donovan Bray <[email protected]> wrote:
> Change the outer heredoc to use %Q{} notation. The inner heredoc will be part 
> of the string and ignored by ruby.
>
> On Nov 13, 2011, at 3:35 AM, hiroysato <[email protected]> wrote:
>
>
>
>
>
>
>
>
>
> > Dear members.
>
> > Does anyone know better way to execute the following command on remote
> > server??
>
> >  run <<-EOS
> >    cat<<EOF | command
> >      #{parameter}
> >      line2
> >      line3
> >    EOF
> >  EOS
>
> > I tried to use here documents, but It does not work correctly.
> > so I'm using the following
>
> >  run <<-EOS
> >    printf "#{parameter}\\nline2\\nline3\\n" > subfile;
> >    command subfile;
> >  EOS
>
> > This is inconvenient. so I'm looking alternative way.
>
> > My alternative idea is create subfile on local host and copy it.
> > but If I can use here documents, It is best way for me.
>
> > Sincerely.
>
> > --
> > Hiroyuki Sato.
>
> > --
> > * You received this message because you are subscribed to the Google Groups 
> > "Capistrano" group.
> > * To post to this group, send email to [email protected]
> > * To unsubscribe from this group, send email to 
> > [email protected] For more options, visit this group 
> > athttp://groups.google.com/group/capistrano?hl=en

-- 
* You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
* To post to this group, send email to [email protected]
* To unsubscribe from this group, send email to 
[email protected] For more options, visit this group at 
http://groups.google.com/group/capistrano?hl=en

Reply via email to