Discussion Locked

munge in a batch symbol table error

0 helpful
17 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

This could be just the nature of Batch files, something causing munge to be unable to do something it can do when directly typed....

I am running munge in a batch file with a simple find and replace of changing "/" to "." I have used munge successfully in batches before, and when I type the command:
"munge munge.txt today.txt" the munge runs successfully. However when my line is put into a batch file, the munge fails with error:
Munge: unable to create symbol table

All of the files for the munge are in the working directory of the batch. The same problem is occurring on two NT workstations one SP5 and the other SP6A
I have read the article on munge and comments at www.winntmag.com, 2 techrepub references, and some useless crap atTechnet with no luck.

can someone please tell me the cause of the error, or the solution, or maybe why the nature of a batch file would change munge's performance parameters and what I can try?

points and kudos for anything that directly leadsme to the fix

17 replies

by timthetoolman

Hi,

It could be the parameters you are using? I'm not sure whether you need to "escape the \" as the batch file may try to do something wierd with it...

When it echos as you run it, does it all appear right?

Cheers,
Tim.

by ngunity

The point of the munge is to get rid of the '/' and replace with a '.', plus removing all spaces.
When typed the munge outputs fine, saying something along the lines of processing line 1, replacing / with . ( I can't recall the exact output of a working munge off the top of my head)

Anyway it just seems crazy that the exact line, typed, vs the line run from a batch performs differently.

I have found another utility I can use to find and replace the strings but I would still be interestedto find out for my own and anyone else's sake why Munge has the "Munge: unable to create symbol table" error.

by timthetoolman

Hi,

Batch operations are different from normal command line stuff. When it comes to character substitution and variable expansion, they behave differently in batch.

I was wondering if the "/" was being interpreted as a " followed by a /" command line "option". That could cause the problem you're seeing.

Cheers,
Tim.

by ngunity

I see what you mean with batches but it won't be applicable as the syntax of the munge command is as follows: munge .txt
whereby file1 is the text doc with changes you want and file2 is the text document you want the changes madeon.
The syntax of file 1 is as follows: "" "" (note there is a space between quotation marks). I.e. my munge file is: "/" "."
and the file it works on is: Fri 16/05/02
When I run the command by typing it produces: fri16.05.02
in the file2, but in a batch it outputs the error.

The other util I've found which is on a 30 day trial before you should buy it is called xchangecl FYI.

by timthetoolman

Hi,

In that case, I dont know what's causing your problem... but from your example, I could see that the following simple command would do the same thing!?

E:\Documents and Settings\Tim Medhurst>date /t > temp.txt

E:\Documents and Settings\Tim Medhurst>type temp.txt
Tue 21/05/2002

E:\Documents and Settings\Tim Medhurst>for /f "tokens=1,2,3* delims=/ " %i in (temp.txt) do echo %i%j.%k.%l

E:\Documents and Settings\Tim Medhurst>echo Tue21.05.2002
Tue21.05.2002

E:\Documents and Settings\Tim Medhurst>

So maybe you dont need to use munge or a similar utility at all? Of course if you're doing other complex substitutions, then it may be easier...

Cheers,
Tim.

by shanghai sam

I don't mind using a purely command line solution however your script had some problems. firstly it's obvious you tested it in Win 2k and it does work as you said in there, but it does not actually CHANGE the contents of the temp.txt file, even whenI run it in Win 2k, although it does echo the date as I'd want it.

In NT it fails with an error: for /f....delims=/" was unexpected at this time.

Also if I am happy with a command line solution then I'll need to understand what is going on in the script so I can change it as needed.

thanks

by timthetoolman

Hi,

Its subtle and hard to see with the TechRepublic interface, but there is actually a space after the slash as in...

...delims=/ " %i in (temp.txt) do...

It means both spaces and /'s are considered delimeters. That might be your problem.I suggest cutting and pasting the line from TR to be sure...

If you do a "for /?" at the command prompt, you'll get the help for "for". Essentially the command reads the first line of the file, parses it for tokens delimited by " "'s and "/"'s, puts them in %i through %l and echo's the results in the format you wanted.

And... you're right. I'm doing it in XP but the command should work in NT too.

And... no it doesn't write it to a file.... but you could easily add a

...in (temp.txt)do echo %i%j.%k.%l >> newfile.txt

To get it appended to "newfile.txt" if thats what you wanted.

If your use of munge is to alter the format of a date, then I'd say the command line version will be easier (and certainly cheaper if you have to buy your alternate tool!)

Cheers,
Tim.

by shanghai sam

Amazingly the problem looks to have come full circle.. I have something that mostly works when typed, but when put into a batch fails....

the following line when run from the command line:
for /f "tokens=1,2,3* delims=/" %i in (date.txt) do echo%i%j.%k.%l >> today.txt
after generating the date.txt file, outputs the file almost exactly as I want it: "wed2205.2002 ." It's getting the '.' in the wrong spot but is mostly right. HOWEVER when run from the batch the exact line echos when run:
for /f "tokens=1,2,3* delims=/" ik.l >> today.txt
and as a result of the line it runs it outputs the error:
ik.l was unexpected at this time

I get the same error in 2k, although I swear in the all the testing I've done it HAS worked properly at least once when typed (not from a batch). Have been checking Syntax 'til my eyes water... what's going wrong?

by timthetoolman

Hi,

I think you may have the wrong syntax. Try this. copy and paste the following line into your batch file...

for /f "tokens=1,2,3* delims=/ " %i in (date.txt) do echo %i%j.%k.%l >> today.txt

I think the above should do what you want it to...
Here are a couple of links to my favorite DOS sites. Not that "favorite" means I actually like DOS... its terribly limited, but nonetheless there are some things it can do that batch file writers should be aware of...

http://www.maem.umr.edu/~batch/batchtoc.htm

http://www.computerhope.com/msdos.htm

http://jason-n3xt.org/dos/help/CMDS.HTM#UNLOCK

(remove spaces from the above URL)

Cheers,
Tim.

by ngunity

My last comments still hold true, I have the syntax right, as I've not only copied your text into Word to max out the size, but I've pasted into batches and so on. Everything I said last time remains, it outputs: ik.l was unexpected at this time
from the batch, but seems to work when typed.... maybe the batch file is doing something to the % sings in the text??

I don't think you'll be able to duplicate my error condition without NT.

I will certainly take a look at the DOS links though, thanks.

Further thought on Answer 6: If I set the regionals to only show the date, not the day I wouldn't have to worry about the space, and maybe with a registry patch I could get every sites settings changed.... still a nightmare for so many dispersed sites...

by pacalealaathotmail.c

One solution would be to change the date separator
for your computer:
Control Panel - Regional Settings - Date -
enter . in Date separator - click Apply.

After the change date /t will give you:
C:\>date /t
Thu 23.05.2002
which can then be redirected to a file or device.

hth

by ngunity

It isn't a bad idea but I have hundreds of locations that the change would need to be made on, so it won't be viable for my solution. Also I still need to get rid of the space between THU and 23.05.2002 in your example above.

thanks

by timthetoolman

Hi,

Sorry. My fault. Yes, in batch you'll need the following...

for /f "tokens=1,2,3* delims=/ " %%i in (date.txt) do echo %%i%%j.%%k.%%l >> today.txt

Cheers,
Tim.

by shanghai sam

All right, that seemed to work well, it's pretty much all done however it seems that now my today.txt file has a bunch of spaces at the end. Let me show you what the rest of the script is doing:

@for /f "delims==," %%i in (today.txt) do set today=%%i
ren dbase.log code%today%.log

So what I am trying to do, now that I've found and replaced on the text file, is set the text in today.txt as a variable in the batch which I then use to rename a file (dbase.log).
Unfortunately the output echos that it runs the rename line like so:
ren dbase.log codeThu23.05.2002 .log
* Which causes it to fail 'cause you can't have the spaces in the filename between the 2 and the ".log"

It's "this" close to suiting my needs exactly, what can be done to get it Just right?

appreciate your help
Nick

by timthetoolman

Hi,

Yep, you can specify the tokens you want *exactly*. Having the 3* means that the last token is the rest of the line, but by changing it to 1,2,3,4 (see below) you'll get the exact date with no spaces.

For example...

E:\Documents and Settings\Tim Medhurst>for /f "tokens=1,2,3,4 delims=/ " %i in (
date.txt) do echo %i%j.%k.%l.log

E:\Documents and Settings\Tim Medhurst>echo Thu23.05.2002.log
Thu23.05.2002.log

Also, I suggest dropping the second text file - today.txt

You canset an environment variable in the for statement like so...

E:\Documents and Settings\Tim Medhurst>for /f "tokens=1,2,3,4 delims=/ " %i in (
date.txt) do set filename=%i%j.%k.%l.log

E:\Documents and Settings\Tim Medhurst>set filename=Thu23.05.2002.log

E:\Documents and Settings\Tim Medhurst>echo %filename%
Thu23.05.2002.log

When you're playing with environment variables in a batch the thigs to watch are use use of %%variable and %variable% to get the information out of them in certain situations.

From memory my links described them... so if its not behaving the way you think.... than that could be it.

Also be very careful with spaces added to you code to make it more readable. Some are ok, but if you put them in the wrong places then they'll stuff up the code too.

For example you must say...

...in (date.txt) do set filename=%i%j.%k.%l.log

and NOT

...in (date.txt) do set filename = %i%j.%k.%l.log

Cheers,
Tim.

by shanghai sam

It's all looking good, the file has finally renamed using the variable, within the script. That's one problem down, many to go

Only just noticed you were in Australia, no wonder you've been replying during business hours...

I really appreciated your assistance, thanks a lot mate.
Nick

This discussion is closed to new replies.