On Sep 4, 2009, at 12:40 PM, James West wrote:
> Aldric Giacomoni wrote:
>> In Windows:
>>>> Dir.chdir 'c:/myscripts'
>> => 0
>>>> Dir.pwd
>> => "c:/myscripts"
>>
>> I think you're making a mountain out of a molehill. Ruby interprets
>> the
>> path properly. Keep it to '/' and do input sanitation when the user
>> tries to give you a '\'
>>
>> Yet, I don't know what you're doing, so..
>
> No mountain, no molehill :-)
> What I'm doing was clearly (I hope) explained in my 2 opening posts
> but
> just to be clear here it is again
>
> I'm actually trying to call cap deploy with the result of this
> function
>
> logger.debug("Creating domain")
> cmd = create_command_line_string("cap cloud_deploy:setup -S
> destination=#{self.requested_url}")
> response = `#{cmd}`
> exit_code = $?
> logger.debug("@@@@ Create domain response = #{response}, Exit
> code =
> #{exit_code}")
> exit_code
>
> This is producing a command "c:/development/cloud/cap
> cloud_deploy:setup
> -S etc..."
> Which is wrong on Windows :-)
>
>>
>>>> PLATFORM
>> => "i386-mswin32"
>
> Thank you :-)
> --
irb> PLATFORM
=> "universal-darwin9.0"
irb> File::SEPARATOR
=> "/"
irb> File::ALT_SEPARATOR
=> nil
Can you use either of these on Windows to construct a suitable gsub?
Guessing:
cmd.gsub!(File::SEPARATOR, File::ALT_SEPARATOR) if
File::ALT_SEPARATOR
Or you can go brute-force with: gsub('/','\\\\')
irb> Dir.pwd
=> "/Users/rab/code/ruby"
irb> Dir.pwd.gsub('/','\\\\')
=> "\\Users\\rab\\code\\ruby"
irb> puts _
\Users\rab\code\ruby
=> nil
-Rob
Rob Biedenharn http://agileconsultingllc.com
[email protected]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" 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/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---