system(" rake db:sample_data:hoop)

J

janus

Hi all,

I need help , why is it that the above code would not run on windows
vista? Is there a known issue why system(".............") does not
work in vista box?

Janus
 
M

Michael Guterl

Hi all,

I need help , why is it that the above code would not run on windows
vista? Is there a known issue why system(".............") does not
work in vista box?

It is likely that I won't be able to help further, but if you could
provide more information that would be great.

What do you mean when you say it does not run on windows vista?

Does ruby segfault? Do you get an exception with a stacktrace?

More specific information will certainly help you to get your problem solved.

Michael Guterl
 
J

janus

It is likely that I won't be able to help further, but if you could
provide more information that would be great.

What do you mean when you say it does not run on windows vista?

Does ruby segfault?  Do you get an exception with a stacktrace?

More specific information will certainly help you to get your problem solved.

Michael Guterl

Ok, this is challenge I have . I have a file with
.......
task :hoop => :environment do
system("db :sample_data:remove")
system("db :sample_data:hap")
end
When I do rake db :sample_data:hoop nothing happens, however , when I
do rake db :sample_data:remove and rake db:sample_data:hap, I get the
expected results.
 
M

Michael Guterl

Hi Janus,

Well maybe I can help.
Ok, this is challenge I have . I have a file with
......
task :hoop => :environment do
system("db :sample_data:remove")
system("db :sample_data:hap")
end
When I do rake db :sample_data:hoop nothing happens, however , when I
do rake db :sample_data:remove and rake db:sample_data:hap, I get the
expected results.

You can find more information by invoking rake with the --trace argument.

rake db:sample_data:remove --trace

On another note, I've never seen a rake task delimited with a ' :'
only with a ':'. You may want to check the code above and remove the
space after db.

One last thing, I think you can invoke the rake tasks without the need
for system. Rake::Task['db:sample_data:remove'].invoke should work if
I recall correctly.

HTH,
Michael Guterl
 
J

janus

Hi Janus,



Well maybe I can help.
You can find more information by invokingrakewith the --trace argument.

rakedb:sample_data:remove --trace

On another note, I've never seen araketask delimited with a ' :'
only with a ':'.  You may want to check the code above and remove the
space after db.

One last thing, I think you can invoke theraketasks without the need
for system.  Rake::Task['db:sample_data:remove'].invoke should work if
I recall correctly.

HTH,
Michael Guterl- Hide quoted text -

- Show quoted text -

On another note, I've never seen araketask delimited with a ' :'
only with a ':'. You may want to check the code above and remove the
space after db.
my mistake.....it was in the code.
 
J

janus

Things have starting moving in the right direction, however,
Rake::Task['db:migrate VERSION=0'].invoke was aborted. What could have
caused this? However, when I did rake db:migrate VERSION=0 on the
console ,I got the expected result.

Janus

Hi Janus,
Well maybe I can help.
You can find more information by invokingrakewith the --trace argument.
rakedb:sample_data:remove --trace
On another note, I've never seen araketask delimited with a ' :'
only with a ':'.  You may want to check the code above and remove the
space after db.
One last thing, I think you can invoke theraketasks without the need
for system.  Rake::Task['db:sample_data:remove'].invoke should work if
I recall correctly.
HTH,
Michael Guterl- Hide quoted text -
- Show quoted text -
On another note, I've never seen araketask delimited with a ' :'
only with a ':'.  You may want to check the code above and remove the
space after db.

my mistake.....it was in the code.- Hide quoted text -

- Show quoted text -
 
M

Michael Guterl

Things have starting moving in the right direction, however,
Rake::Task['db:migrate VERSION=0'].invoke was aborted. What could have
caused this? However, when I did rake db:migrate VERSION=0 on the
console ,I got the expected result.

Once again, the actual error would be helpful. Be sure to include
that with any other future problems.

However, it seems that you're thinking Rake::Task[] works like
system(). This is not the case, Rake::Task[] only looks up the
corresponding task with that name. It is likely that there is no
Rake::Task defined with the name 'db:migrate VERSION=0'.

The VERSION=0 part is not a part of the task name, but an environment
variable that Rake reads from in the db:migrate task. I'm not sure of
the recommended method of setting environment variables, when using
the Rake::Task[].invoke method.

I cannot test at the moment:

ENV['VERSION'] = 0
Rake::Task["db:migrate"].invoke

but I think that should work.

HTH,
Michael Guterl
 
J

janus

ENV['VERSION'] = 0
Rake::Task["db:migrate"].invoke

but I think that should work.
It worked, I only changed Fixnum 0 to string. Could you explain the
difference between system("rake.....") and Rake::Task["......"]

Janus



Things have starting moving in the right direction, however,
Rake::Task['db:migrate VERSION=0'].invoke was aborted. What could have
caused this? However, when I didrakedb:migrate VERSION=0 on the
console ,I got the expected result.

Once again, the actual error would be helpful.  Be sure to include
that with any other future problems.

However, it seems that you're thinkingRake::Task[] works like
system().  This is not the case,Rake::Task[] only looks up the
corresponding task with that name.  It is likely that there is noRake::Task defined with the name 'db:migrate VERSION=0'.

The VERSION=0 part is not a part of the task name, but an environment
variable thatRakereads from in the db:migrate task.  I'm not sure of
the recommended method of setting environment variables, when using
theRake::Task[].invoke method.

I cannot test at the moment:

ENV['VERSION'] = 0Rake::Task["db:migrate"].invoke

but I think that should work.

HTH,
Michael Guterl
 
M

Michael Guterl

Hi Janus,

ENV['VERSION'] = 0
Rake::Task["db:migrate"].invoke

but I think that should work.
It worked, I only changed Fixnum 0 to string. Could you explain the
difference between system("rake.....") and Rake::Task["......"]
Great, I'm glad you got things working.

system is a class method that belongs to Kernel. In order to find out
what it does, we can run the following:

macbook:~ michaelguterl$ ri Kernel.system

---------------------------------------------------------- Kernel#system
system(cmd [, arg, ...]) => true or false
------------------------------------------------------------------------------------------------------
Executes _cmd_ in a subshell, returning +true+ if the command was
found and ran successfully, +false+ otherwise. An error status is
available in +$?+. The arguments are processed in the same way as
for +Kernel::exec+.

system("echo *")
system("echo", "*")

------------------------------------------------------------------------------------------------------

Moving along from http://rake.rubyforge.org

Rake::Task#[](task_name)

Return a task with the given name. If the task is not currently known,
try to synthesize one from the defined rules. If no rules are found, but an
existing file matches the task name, assume it is a file task with no
dependencies or actions.

So Kernel.system() executes a command in a subshell and Rake::Task#[]
retrieves the task given name. I hope that clarifies things a bit.

Michael Guterl
 
J

janus

Some strange result, on my console Rake::Task["db:migrate"].invoke
prints the list of tables created, however nothing in the database.
When I try system("rake.bat.....") becuase I am using windows, this
creates the tables.

Janus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,200
Messages
2,571,046
Members
47,646
Latest member
xayaci5906

Latest Threads

Top