Try a blank line between the last foo and EOS
What you have looks like it should have worked to me
As an alternative I might try
lines = %w(foo foo foo).inject(0) do |v,f|
count = capture("cat #{f} | wc -l").chomp
logger.info "#{f} #{count}"
v += count
end
logger.info "lines: #{lines}"
The downside besides being more complex and issuing more ssh commands this will
only measure the line count of one server; if that doesn't matter then it might
be good enough.
On Nov 14, 2011, at 9:05 PM, hiroysato <[email protected]> wrote:
> Hello Donovan.
>
> Thank you for your information.
>
> I tried two pattern. but It does not work correctly too.
>
> role :server, "user@server"
> task :heredoctest, :roles => :server do
> run %Q{
> cat<<EOS|wc -l
> foo
> foo
> foo
> EOS
>
> }
> end
>
> role :server, "user@server"
> task :heredoctest, :roles => :server do
> run %Q{
> cat<<EOS|wc -l
> foo
> foo
> foo
> EOS
> #
> }
> end
>
>
> * executing `heredoctest'
> * executing "cat<<EOS|wc -l \\\n foo \\\n foo \\\n
> foo \\\nEOS\\\n#"
> servers: ["server"]
> [user@server] executing command
> *** [err :: user@server] sh: line 5: warning: here-document at line 5
> 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] foo
> *** [err :: user@server] : No such file or directory
> *** [err :: user@server]
> *** [err :: user@server] wc:
> *** [err :: user@server] EOS#
> *** [err :: user@server] : No such file or directory
> *** [err :: user@server]
> ** [out :: user@server] 0 total
> command finished in 48ms
> failed: "sh -c 'cat<<EOS|wc -l \\\n foo \\\n foo \\
> \n foo \\\nEOS\\\n#'" on user@server
>
>
> On 11月15日, 午前1:24, Donovan Bray <[email protected]> wrote:
>> Try putting a line ending after EOS
>>
>> EOS
>>
>> }
>>
>> Also you can do
>>
>> run %Q{
>> ...
>>
>> }
>>
>> And get rid of the intermediate variable.
>>
>> On Nov 14, 2011, at 1:17 AM, hiroysato <[email protected]> wrote:
>>
>>
>>
>>
>>
>>
>>
>>> EOS
>>> }
>
> --
> * 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
--
* 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