Alex Gutteridge
4/26/2007 7:45:00 AM
On 26 Apr 2007, at 15:59, Dhiraj Girdhar wrote:
> Alex Gutteridge wrote:
>> On 26 Apr 2007, at 15:33, Dhiraj Girdhar wrote:
>>
>>>> Bioinformatics Center
>>>> Kyoto University
>>>
>>> Please tell me if i have a script file say scriptfile, then how i
>>> can
>>> run that file using ruby.
>>> Please explaain with example.
>>
>> I was a bit terse with my previous answer. I was just pointing out
>> that you had a space between the initial '.' and the rest of your
>> command which would cause system() to fail. Here is an example of how
>> to run a script using system():
>>
>> [alexg@powerbook]/Users/alexg(5): cat test.sh
>> #!/bin/sh
>>
>> echo 'foo'
>> [alexg@powerbook]/Users/alexg(6): ./test.sh
>> foo
>> [alexg@powerbook]/Users/alexg(7): ruby -e "system('./test.sh')"
>> foo
>>
>> Alex Gutteridge
>>
>> Bioinformatics Center
>> Kyoto University
>
> I tried above in following manner, but i got following error.
> 1) I created one script file name :sample
> with following data
> #!/bin/sh
>
> echo 'foo'
>
> Then i created a test.rb file with following code
>
> abc = system("./sample")
> puts $?
> puts abc
>
> Note: Both files are in same folder.
>
> when i executed the test file with following command
>
> ruby test.rb
>
> I got following result
>
> test.rb:2: warning: Insecure world writable dir
> /opt/oracle/product/10.2.0/client_1/bin, mode 040777
> 32512
> false
>
> Please try the same.
> OS : Solaris
> Ruby Version: 1.8.5
Sorry, I don't have access to a Solaris machine so I can't reproduce
the error. And I have no idea what a 32512 error code means. Your
code looks fine to me, so I'm not sure what the problem could be.
Good luck.
Alex Gutteridge
Bioinformatics Center
Kyoto University