Re: UNIX tr utility written in vbscript
- From: "Al Dunbar" <alandrub@xxxxxxxxxxx>
- Date: Sat, 3 Oct 2009 12:46:43 -0600
"ggrothendieck" <ggrothendieck@xxxxxxxxx> wrote in message news:7b545e7c-533a-404d-a03b-3d5df49196a5@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Oct 3, 12:49 pm, "Al Dunbar" <aland...@xxxxxxxxxxx> wrote:"Richard Mueller [MVP]" <rlmueller-nos...@xxxxxxxxxxxxxxxxxxxx> wrote in
messagenews:O5oNs$DRKHA.4020@xxxxxxxxxxxxxxxxxxxxxxx
> "ggrothendieck" <ggrothendi...@xxxxxxxxx> wrote in message
>news:39cbdaa2-0ebb-4d65-be36-5e63158c3c97@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> On Oct 3, 11:15 am, "ekkehard.horner" <ekkehard.hor...@xxxxxxxx>
> wrote:
>> ggrothendieck schrieb:
>> > On Oct 3, 3:43 am, "ekkehard.horner" <ekkehard.hor...@xxxxxxxx> >> > wrote:
>> >> '' tr-00.vbs - trivial/reduced version of unix tr
>> [...]
>> > Thanks. That's great.
>> > With argument processing to get sSearch and sReplace from the >> > command
>> > line that would become a usable off-the-shelf utility that could
>> > handle many practical situations.
>> So let's start the 'lot of work':
>> '' tr-00.vbs - trivial/reduced version of unix tr
> Many thanks. This is much more than I expected.
> One additional item. Does anyone have a trick of combining a batch
> file and a vbs file in the same physical file so that if can be called
> like this:
> tr-00 from to < infile
> and then tr-00.bat calls itself but as a vbscript file using cscript
> so that we don't have to write cscript tr-00.vbs but just tr-00.
> -----------------
> A batch file can run a VBScript program, and you can pass the name of > the
> VBScript to the batch file as a parameter. The batch file could be:
> =========
> @echo off
> cscript //nologo %1
> ========
> If the batch file is called tr-00.bat, you could run the VBScript > program
> Example.vbs with the following command:
> tr-00 Example.vbs
> And you can get fancy and have the batch file first check to make sure > the
> parameter was supplied.
I believe the OP wanted both scripts to reside in the same file, rather than
in two files with the same base name and location.
If so, there are a couple of approaches:
- write a batch script that creates the vbscript file to be called. This
should be located in %temp% where the user will have the required
permissions, and where two concurrent users (if on a shared folder) will not
interfere with each other.
- write a vbscript that creates the batch script file to be called. This
should be located in %temp% where the user will have the required
permissions, and where two concurrent users (if on a shared folder) will not
interfere with each other.
It might be possible to avoid having to create the second script file to be
called altogether, but that would require two things:
- combining the two scripts syntactically in such a way as to cause each
scripting host (vbscript and batch) to ignore as comments or skip over the
script of the other language without throwing errors. I have seen examples
of this with other language combinations.
- getting one of the scripting hosts to accept script in a file with an
unexpected file type. This might be possible with WSH, however, I have not
tried it myself.
Yes, I am looking for a trick along these lines and would prefer not
to have to write out any files.
OK, then, all you need to do is to find a way to combine both languages into a .cmd file, run it as a batch script, and have the following batch command to re-launch the vbscript code in the script:
cscript.exe //nologo /e:vbscript "%~dpnx0"
We will be interested in seeing what you come up with...
/Al
.
- Follow-Ups:
- Re: UNIX tr utility written in vbscript
- From: ggrothendieck
- Re: UNIX tr utility written in vbscript
- References:
- UNIX tr utility written in vbscript
- From: ggrothendieck
- Re: UNIX tr utility written in vbscript
- From: ekkehard.horner
- Re: UNIX tr utility written in vbscript
- From: ggrothendieck
- Re: UNIX tr utility written in vbscript
- From: ekkehard.horner
- Re: UNIX tr utility written in vbscript
- From: ggrothendieck
- Re: UNIX tr utility written in vbscript
- From: Richard Mueller [MVP]
- Re: UNIX tr utility written in vbscript
- From: Al Dunbar
- Re: UNIX tr utility written in vbscript
- From: ggrothendieck
- UNIX tr utility written in vbscript
- Prev by Date: Re: UNIX tr utility written in vbscript
- Next by Date: Re: UNIX tr utility written in vbscript
- Previous by thread: Re: UNIX tr utility written in vbscript
- Next by thread: Re: UNIX tr utility written in vbscript
- Index(es):
Relevant Pages
|