[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Windows - calling system with multiple parms

colotechpro

11/21/2004 3:41:00 AM

I'm having a problem getting a system call to Windows XP to work. I
upgraded my Ruby from 1.6.8 to 1.8.1 recently.

System info:

>ruby ?v
ruby 1.8.1 (2003-12-25) [I-386-mswin32]


FWIW, my .bat file is passing the directory path for ghostscipt exe
and the path for the ghostscript font directory, as well as the
printer code for the ghostscript emulation.

This line of code worked when I was on 1.6.8:

system("dcpropgst.bat", [@@gsdir, @@gsfontdir, @@prttxt])

Now, I get the TypeError: cannot convert Array into String

I've tried many different ways of calling system with one of them
being:

system( %{"dcpropgst.bat", #@@gsdir, #@@gsfontdir, #@@prttxt} )

In all cases where I can see that it is calling the .bat file, only
the 1st parameter is being passed.


I've spent many hours trying to get it to work. What do I need to
change so all 3 parms are passed?

Thanks,

John Reed
12 Answers

Florian Gross

11/21/2004 5:26:00 AM

0

John Reed wrote:

> I'm having a problem getting a system call to Windows XP to work. I
> upgraded my Ruby from 1.6.8 to 1.8.1 recently.
>
> system("dcpropgst.bat", [@@gsdir, @@gsfontdir, @@prttxt])

irb(main):011:0> system("ruby", "-v", "-c", "-e()")
ruby 1.8.2 (2004-07-16) [i386-mswin32]
Syntax OK

Does this not work for you?

Austin Ziegler

11/21/2004 2:36:00 PM

0

On Sun, 21 Nov 2004 12:43:07 +0900, John Reed <colotechpro@yahoo.com> wrote:
> I'm having a problem getting a system call to Windows XP to work. I
> upgraded my Ruby from 1.6.8 to 1.8.1 recently.
>
> System info:
>
> >ruby â??v
> ruby 1.8.1 (2003-12-25) [I-386-mswin32]
>
> FWIW, my .bat file is passing the directory path for ghostscipt exe
> and the path for the ghostscript font directory, as well as the
> printer code for the ghostscript emulation.
>
> This line of code worked when I was on 1.6.8:
>
> system("dcpropgst.bat", [@@gsdir, @@gsfontdir, @@prttxt])

Try changing this to:
system("dcpropgst.bat", @@gsdir, @@gsfontdir, @@prttxt)

If you can't predict how many parameters, do this:
params = [ @@gsdir, @@gsfontdir, @@prttxt ]
system("dcpropgst.bat, *params)

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca



colotechpro

11/21/2004 5:05:00 PM

0

Florian Gross asked:
> irb(main):011:0> system("ruby", "-v", "-c", "-e()")
> ruby 1.8.2 (2004-07-16) [i386-mswin32]
> Syntax OK
>
> Does this not work for you?


Florian, it does work for me:

C:\ruby>irb
irb(main):001:0> system("ruby", "-v", "-c", "-e()")
ruby 1.8.1 (2003-12-25) [i386-mswin32]
Syntax OK
=> true

John

colotechpro

11/22/2004 12:36:00 AM

0

Austin,
AZ> Try changing this to:
AZ> system("dcpropgst.bat", @@gsdir, @@gsfontdir, @@prttxt)

This doesn't call the .bat file at all.
>
AZ> If you can't predict how many parameters, do this:
AZ> params = [ @@gsdir, @@gsfontdir, @@prttxt ]
AZ> system("dcpropgst.bat", *params)

Neither does this one.

If I wanted to hard code the paths as well as the printer code, it
will work.

What I see happening is that when I pass the 3 parameters as I think
that they should be passed is that the 2nd & 3rd params aren't in fact
passed.

Here is dcpropgst.bat:
%1 -I%2 -sDEVICE=%3 -dNOPAUSE print.ps -c quit

This:
system( %{"dcpropgst.bat",#{@@gsdir} #{@@gsfontdir} #{@@prttxt}} )

(or this because the braces aren't needed)
system( %{"dcpropgst.bat",#@@gsdir #@@gsfontdir #@@prttxt} )

Causes this:
C:\JDR\Ruby>C:\DCPro\gs\gs8.14\bin\gswin32.exe -I -sDEVICE= -dNOPAUSE
print.ps -c quit

Putting commas between the params is also irrelevant, in my testing,
as they all produce the above result.


John Reed

Florian Gross

11/22/2004 1:38:00 PM

0

John Reed wrote:

> What I see happening is that when I pass the 3 parameters as I think
> that they should be passed is that the 2nd & 3rd params aren't in fact
> passed.
>
> Here is dcpropgst.bat:
> %1 -I%2 -sDEVICE=%3 -dNOPAUSE print.ps -c quit
>
> This:
> system( %{"dcpropgst.bat",#{@@gsdir} #{@@gsfontdir} #{@@prttxt}} )
>
> (or this because the braces aren't needed)
> system( %{"dcpropgst.bat",#@@gsdir #@@gsfontdir #@@prttxt} )

p [@@gsdir, @@gsfontdir, @@prttxt]

I expect all of those to be nil or empty strings. I can't tell you how
to fix that without having the source code of your application.

colotechpro

11/23/2004 4:01:00 AM

0

> p [@@gsdir, @@gsfontdir, @@prttxt]
>
> I expect all of those to be nil or empty strings. I can't tell you how
> to fix that without having the source code of your application.

Ah, if only it were that easy. I do a "puts" of those variables before
the system call and they are properly populated.

I still don't get why it worked with 1.6.8 and not 1.8.1...doesn't
make sense to me.

John Reed

Lyndon Samson

11/23/2004 12:41:00 PM

0

Cant you do

system("dcpropgst.bat #{@@gsdir} #{@@gsfontdir} #{@@prttxt}")

?


colotechpro

11/24/2004 4:50:00 AM

0

Lyndon Samson <lyndon.samson@gmail.com> wrote in message news:<a39f6ad004112304417332368b@mail.gmail.com>...
> Cant you do
>
> system("dcpropgst.bat #{@@gsdir} #{@@gsfontdir} #{@@prttxt}")
>
> ?

Same results as before, not passing the 2nd and 3rd parameters.

I put an echo in the .bat file to see the parameters, so here is the
results of the .bat file as it is called:

C:\JDR\Ruby>echo C:\DCPro\gs\gs8.14\bin\gswin32.exe
C:\DCPro\gs\gs8.14\bin\gswin32.exe

C:\JDR\Ruby>echo
ECHO is on.

C:\JDR\Ruby>echo
ECHO is on.

C:\JDR\Ruby>C:\DCPro\gs\gs8.14\bin\gswin32.exe -I -sDEVICE= -dNOPAUSE
print.ps -c quit

Here is the complete .bat file:
echo %1
echo %2
echo %3
%1 -I%2 -sDEVICE=%3 -dNOPAUSE print.ps -c quit


I do have 3 "puts" right before the system call so I can see that all
of the params have the values that I expect them to.

@@gsdir = C:\DCPro\gs\gs8.14\bin\gswin32.exe
@@gsfontdir = C:\DCPro\gs\gs8.14\bin\fonts
@@prttxt = cdj550

Well, I'm back to the drawing board on this problem....

JReed

Lyndon Samson

11/24/2004 6:30:00 AM

0

Try using literals rather than your class variables.

Then use instance variables.


colotechpro

11/27/2004 5:10:00 AM

0

Lyndon Samson <lyndon.samson@gmail.com> wrote in message news:<a39f6ad0041123222938c10391@mail.gmail.com>...
> Try using literals rather than your class variables.
>
> Then use instance variables.

Good ideas, but I never could make it work with more than 1 parameter.
I found a workaround in the batch file itself.

John Reed