I looked at the some bash pages and I believe this to be the correct invocation
cat | wc -l <<EOS As unlikely as it seems, give it a try. http://tldp.org/LDP/abs/html/here-docs.html You might check into using xargs unfortunately I can't recite xargs syntax from memory run "echo foo foo foo | xargs ... On Nov 17, 2011, at 6:35 PM, hiroysato <[email protected]> wrote: > Hello Donovan. > > Thank you for your information. > > I tried following. but It does not work correctly too. > > run %Q{ > cat<<EOS | wc -l > foo > foo > foo > > EOS > # > } > > > > On 11月16日, 午前1:34, Donovan Bray <[email protected]> wrote: >> 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}" > > Thank you for your advice. > However, It is just simplified example. > > I would like to execute sql script with pipe(or alternative way) on > remote server. > > I'll change my mind. I'll copy it from local server. > > > >> >> 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 >>> 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 -- * 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
