Re: UNIX tr utility written in vbscript

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"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


.



Relevant Pages

  • Re: making a script
    ... batch command: executed successfully. ... I have used gimp's batch processing only slightly, ... You are using the batch mode to execute a scheme script ...
    (comp.graphics.apps.gimp)
  • Re: Copying files based on date during logon
    ... OR Should I be looking at going towards a more advanced VBscript ... > To me the use of xcopy seems like a hack, ... If most of it is batch, ... There are a few things you could do to simplify your batch script, ...
    (microsoft.public.windows.server.scripting)
  • Re: Testing for Interactive or Batch Mode
    ... When I run a script from the command line with a command like "gnuplot ... run in batch mode or loaded in interactive mode? ... mode for the duration of any load command, ...
    (comp.graphics.apps.gnuplot)
  • Re: Windows "Scheduled Task Wizard..."
    ... Do you know any links at Microsoft documents related to the batch file ... command name to get started. ... VB Script and any other Microsoft scripting languages have nice ...
    (microsoft.public.windows.server.general)
  • Re: Using Redirect/Pipe within a VBscript
    ... to work within a VBscript, have been working on this for 2 weeks and have tried a multitude of different solutions. ... The script runs a Microsoft tool called psexec which I use to connect to a remote Cisco CallManager server running Windows 2000 Server. ... It then runs a command called mmfspy.exe with an argument, ... The results of 'mmfspy i' is redirected to a text file on my Windows 2000 Pro workstation. ...
    (microsoft.public.scripting.vbscript)