James West wrote:
> Hi,
> Depenbding on whether running under windows or unix/mac I obviously need
> to use the \ instead of the / character for shell commands so I have 2
> questions really
> 1) I would love to know if anyone has a neat way of dealing with
> converting paths to use '\' instead of '/' for use with command line
> calls like command and backtick?
>
> 2) How to determine the applications Operating System environment?
>
> This is the function I need it for
>
> def create_command_line_string(cmd)
> result = Rails.root.join(cmd)
> logger.debug("@@@@ - #{result}")
> result
> end
>
> Any ideas or pointers would be greatly appreciated
Just an adendum to this.
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 fine on the server as the Rails.root will give me the correct
application root path but not on development.
In development I obviously need to just replace the / slashes with \
slashes.
It would be nice though if the ` backtick usage actually returned
something. Anything at all would be good but the output from the
logger.debug looks like this
@@@@ Create domain response = , Exit code =
So maybe backticks are not the right solution? Is there something that
will give me more info over what is going on so I can deal with results
more effectively?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---