[GLLUG] SED Emergency
Brian Hoort
hoortbri@msu.edu
Mon, 12 May 2003 10:01:31 -0400
I'm way behind on a deadline and can't get a da*n SED script to function
properly on Win XP. Please help ASAP if you are able. I realize I'm trying
to use a un*x app on Win, but please try and imagine the helpful response I
would get by asking a Windows list group this question. In addition, great
stuff like SED help bring Linux into Windows shops (like mine).
Background:
I'm setting up XP computers for a student computer lab. In order to get
apps to behave properly for new users, I have to configure the Default User
so that apps are already setup, and users aren't asked to register or
configure apps, etc. Netscape 7.02 (should be very similar to Mozilla) has
a path hard-coded into a file in the users profile\Application Data\Mozilla
folder called 'registry.dat' with the users profile path, and thereby their
username. I need to change this path to %USERNAME% so that it points to the
actual users profile, not the profile of the user I'm using to setup this
computer. If you don't follow, just forget about it, it's not really
required to solve this problem.
Here is the script:
c:\progra~1\util\sed.exe "s\gradsetup\%USERNAME%\g" registry.dat >registry.new
pause
Here is the output (I split it and added the '\' chars):
C:\Documents and Settings\gradsetup\Application Data\Mozilla>\
c:\progra~1\util\sed.exe "gradsetup\s\gradsetup\gradsetup\g"\
registry.dat 1>"registry.new" c:/progra~1/util/sed.exe:\
-e expression #1, char 2: Extra characters after command
C:\DOCUME~1\GRADSE~1\APPLIC~1\Mozilla>pause
Press any key to continue . . .
Please notice in the above output the '1' that has been inserted before the
'>' and is 2 characters after the input filename. This appears every time,
and it's not in the batch file.
I should also point out that the input file is binary. Is that a problem?
The section of text is there if I open with Notepad and search for it.
I suspect this has something to do with the version of sed I'm using not
being able to handle DOS ANSI text from the batch file properly, and it is
misinterpreting the '>' character, or something along those lines. Please
note that I've used this method in the lab before, had the same problem,
but somehow got around it by removing the spaces around the '>' in the
following command (this command is one, long line):
c:\progra~1\util\reg.exe query
"HKLM\System\CurrentControlSet\Control\Current
User"|c:\progra~1\util\sed.exe -e "s\REG_SZ\\g;s\Current
User\\g;s/^[ ]*//;s/[ ^]*$//;s/.* //;s/^/c:\\progra~1\\util\\winset.exe
USERNAME=/">c:\windows\temp\SETUSER.BAT
Thanks a lot!
________________________________________________________________________________
Brian Hoort | Agricultural Economics Computer Service, Michigan State
University
"Be the change you want to see in the world" -Mahatma Gandhi