Getting closer! Something is wacked with my shell:

% sh -c "echo today is \`date\`"
today is

% sh --version
GNU bash, version 3.1.17(1)-release (i686-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

Perhaps I have some environment variable set wrong or something?

Jamis, the capfile I posted in my original message is the complete
capfile. I tried adding set :shell, false and it made no difference.

I suppose the change I made to command.rb is incorrect because the
backticked command will be run locally instead of remotely. (Right?)


On 19 May, 09:47, Jamis Buck <[email protected]> wrote:
> The reason it is escaped is because Capistrano invokes the command via
> 'sh' (by default). E.g., the following run command:
>
>    run "echo today is `date`"
>
> Gets translated into the following shell command:
>
>    sh -c "echo today is \`date\`"
>
> The backticks need to be escaped so that they get evaluated by the inner
> shell, and not the outer shell.
>
> That said, what does the rest of your capfile look like? Are you setting
> :shell anywhere? What version of the posix shell do you have on your
> remote host?
>
> You might also try setting :shell to false, so that all commands are
> invoked directly:
>
>    set :shell, false
>
> That way, commands will be run without wrapping them in a "sh -c ..." call.
>
> - Jamis
>
> On 5/19/09 10:33 AM, Scott Johnson wrote:
>
> > I don't believe it is a permissions thing. I can run the same command
> > not in backticks and it works. I can run the backticked command
> > directly (not through Capistrano) and it works as expected:
>
> > date is Tue May 19 09:25:51 PDT 2009 so there
>
> > And I can edit Capistrano's source as described above and get it to
> > work.
>
> > There is something going on with Capistrano's escaping of the
> > backticks that I don't understand. Why is it necessary on every
> > computer except mine to escape the backticks? And why, when they are
> > escaped on my machine, does the backticked command simply disappear
> > without a trace?
>
> > I can't imagine what could be so different on my machine. I realize
> > I'm running an old Fedora, but things like backticks and shell escape
> > characters haven't changed in 25 years.
>
> > On 19 May, 08:10, Lee Hambley<[email protected]>  wrote:
> >> Scott,
> >> Hate to respond with a classic `worksforme` -- may it be that your user
> >> (humor me) doesn't have access to do any of the things you are asking, try
> >> something like run('touch `echo date`') or similar.
>
> >> To save potential email formatting issues, please post the code, output and
> >> error all in a gist/pastie and post us the links.
>
> >> - Lee
>
> >> 2009/5/19 Scott Johnson<[email protected]>
>
> >>> No difference. Not only is the output of the backticked command not
> >>> getting into the string, the command itself is never being run. I can
> >>> replace the command with `touch file.txt` and that file is never
> >>> created.
> >>> On 19 May, 01:26, Lee Hambley<[email protected]>  wrote:
> >>>> Try,
> >>>> task :foo, :hosts =>  "my.host.com" do
> >>>>   run "echo date is `cat /bin/date` so there"
> >>>> end
> >>>> 2009/5/19 Scott Johnson<[email protected]>
> >>>>> I have a run command that uses shell backticks, yet the command in the
> >>>>> backticks never runs and I get an empty string instead of the output
> >>>>> of the command.
> >>>>> My Capfile:
> >>>>> task :foo, :hosts =>  "my.host.com" do
> >>>>>   run "echo date is `/bin/date` so there"
> >>>>> end
> >>>>> Output from running 'cap foo':
> >>>>>   * executing 'foo'
> >>>>>   * executing "echo date is `/bin/date` so there"
> >>>>>     servers: ["my.host.com"]
> >>>>>     [my.host.com] executing command
> >>>>>   ** [out :: my.host.com] date is  so there
> >>>>>     command finished
> >>>>> Bizarre.
> >>>>> I'm running cap 2.5.5 on Fedora Core release 6 with Ruby 1.8.7. The
> >>>>> local and remote machine are the same (ie, I'm launching cap from
> >>>>> my.host.com).
> >>>>> If I edit line 212 of lib/capistrano/command.rb (that escapes certain
> >>>>> special characters in the command) and remove the backtick from the
> >>>>> gsub args, it works. But I somehow doubt this is the proper solution,
> >>>>> since I seem to be the only one having this problem.
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to