Forum: Ruby Need to carry over application variable into RUBY script

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B58c6eef325656d513d26e2c3ae6bfd9?d=identicon&s=25 Peter Bailey (peterbailey)
on 2006-04-17 18:13
I have an application that converts PDFs to individual EPS files. When
it does so, it creates a subdirectory with the same name as the original
filename and puts all of the resulting EPS files it creates into that
directory. Well, I have to do a lot of scripting and stuff on those EPS
files. To automate this, I need to know what the directory name is that
it put the files. The application provides a variable, "%2," just for
this purpose. I've gotten this %2 variable to work for me in cmd.exe.
But, I'd like it to work in RUBY. I'm sure it can be done. But, came
someone tell me how I can transfer this %2 variable from my application
to a Dir.chdir target?

Example:
A 100 page PDF comes in named IRSp590. The application creates a
subdirectory named "IRSp590." All of the files the application creates
are put into this directory. I just need to get into that directory,
wherever it is, and do stuff to the files.

Thanks.
31ab75f7ddda241830659630746cdd3a?d=identicon&s=25 Austin Ziegler (Guest)
on 2006-04-17 18:19
(Received via mailing list)
On 4/17/06, Peter Bailey <pbailey@bna.com> wrote:
> I have an application that converts PDFs to individual EPS files. When
> it does so, it creates a subdirectory with the same name as the original
> filename and puts all of the resulting EPS files it creates into that
> directory. Well, I have to do a lot of scripting and stuff on those EPS
> files. To automate this, I need to know what the directory name is that
> it put the files. The application provides a variable, "%2," just for
> this purpose. I've gotten this %2 variable to work for me in cmd.exe.
> But, I'd like it to work in RUBY. I'm sure it can be done. But, came
> someone tell me how I can transfer this %2 variable from my application
> to a Dir.chdir target?

%2 is the 2nd argument on the command-line, so you just have to look
for ARGV[2].

It'd be interesting to find out what %1 is ;)

-austin
B58c6eef325656d513d26e2c3ae6bfd9?d=identicon&s=25 Peter Bailey (peterbailey)
on 2006-04-17 19:13
Austin Ziegler wrote:
> On 4/17/06, Peter Bailey <pbailey@bna.com> wrote:
>> I have an application that converts PDFs to individual EPS files. When
>> it does so, it creates a subdirectory with the same name as the original
>> filename and puts all of the resulting EPS files it creates into that
>> directory. Well, I have to do a lot of scripting and stuff on those EPS
>> files. To automate this, I need to know what the directory name is that
>> it put the files. The application provides a variable, "%2," just for
>> this purpose. I've gotten this %2 variable to work for me in cmd.exe.
>> But, I'd like it to work in RUBY. I'm sure it can be done. But, came
>> someone tell me how I can transfer this %2 variable from my application
>> to a Dir.chdir target?
>
> %2 is the 2nd argument on the command-line, so you just have to look
> for ARGV[2].
>
> It'd be interesting to find out what %1 is ;)
>
> -austin

Thanks, Austin. So, do I do this?

 Dir.chdir(ARGV[2])
 or this
 Dir.chdir("ARGV[2]")?
31ab75f7ddda241830659630746cdd3a?d=identicon&s=25 Austin Ziegler (Guest)
on 2006-04-17 19:43
(Received via mailing list)
On 4/17/06, Peter Bailey <pbailey@bna.com> wrote:
> >> someone tell me how I can transfer this %2 variable from my application
>  Dir.chdir("ARGV[2]")?
Never the latter.

I'm presuming that what you actually have is a command-line entry box
in your Windows program:

   [ post_process_script %2 ]

If that's how you're configuring it, then your Ruby code must be
looking for ARGV[1], not ARGV[2].

-austin
B58c6eef325656d513d26e2c3ae6bfd9?d=identicon&s=25 Peter Bailey (peterbailey)
on 2006-04-17 20:24
Austin Ziegler wrote:
> On 4/17/06, Peter Bailey <pbailey@bna.com> wrote:
>> >> someone tell me how I can transfer this %2 variable from my application
>>  Dir.chdir("ARGV[2]")?
> Never the latter.
>
> I'm presuming that what you actually have is a command-line entry box
> in your Windows program:
>
>    [ post_process_script %2 ]
>
> If that's how you're configuring it, then your Ruby code must be
> looking for ARGV[1], not ARGV[2].
>
> -austin

No, there's no command line entry box. It's just an understood variable
that the application can use in a post-processing script, which, usually
is, of course, a .cmd script. In a simple Windows script, for example,
you could do this:
       cd %2
and you would go to the directory path of the file that the application
produced.
31ab75f7ddda241830659630746cdd3a?d=identicon&s=25 Austin Ziegler (Guest)
on 2006-04-17 20:32
(Received via mailing list)
On 4/17/06, Peter Bailey <pbailey@bna.com> wrote:
> No, there's no command line entry box. It's just an understood variable
> that the application can use in a post-processing script, which, usually
> is, of course, a .cmd script. In a simple Windows script, for example,
> you could do this:
>        cd %2
> and you would go to the directory path of the file that the application
> produced.

OK. Then you need ARGV[2].

-austin
B58c6eef325656d513d26e2c3ae6bfd9?d=identicon&s=25 Peter Bailey (peterbailey)
on 2006-04-17 20:47
Austin Ziegler wrote:
> On 4/17/06, Peter Bailey <pbailey@bna.com> wrote:
>> No, there's no command line entry box. It's just an understood variable
>> that the application can use in a post-processing script, which, usually
>> is, of course, a .cmd script. In a simple Windows script, for example,
>> you could do this:
>>        cd %2
>> and you would go to the directory path of the file that the application
>> produced.
>
> OK. Then you need ARGV[2].
>
> -austin

Thank you!
This topic is locked and can not be replied to.