Fencer128 Posted September 15, 2005 Share Posted September 15, 2005 (edited) Hi,I'm working on a batch file that alters the contents of a couple of text files as part of its operation. I use the "Fedit" utility (picked it up from Bashrat's Driver Packs) to edit the text.I'm having a problem editing a couple of lines of text that contain escape characters. I do not know if there's an easy way round this, but since my batch file expertise is far more limited than some people's around here I thought I'd try begging!Here is the pertient part of the text file that will be edited:...%CD%\FILES\ROBOCOPY "%FOLDER%" "%UWXPCD%" *.* /E %RS%...Here is an example of the type of batch file operation that is causing me hassle:FEDIT -ADD -ONCE -F %BTS%\textfile.cmd -A "%CD%\FILES\ROBOCOPY "%FOLDER%" "%UWXPCD%" *.* /E %RS%" -L "%RUNFROM%\FILES\ROBOCOPY "%FOLDER%" "%UWXPCD%" *.* /E %RS%"The syntax of Fedit expects:FEDIT -ADD -ONCE -F <filename> -A "<line of text>" - L "<line of text>"The operation should result in the text following -L to be added directly underneath the line following -AThe problem appears to be the prescence of % and " in the command line. I've tried removing the extra quotes, using /" and /% but nothing works correctly.Does anyone have a way around this?Thank you,Andy Edited September 15, 2005 by Fencer128 Link to comment Share on other sites More sharing options...
cmarcusson Posted September 15, 2005 Share Posted September 15, 2005 Try This...FEDIT -ADD -ONCE -F %BTS%\textfile.cmd -A "%%CD%%\FILES\ROBOCOPY "%%FOLDER%%" "%%UWXPCD%%" *.* /E %%RS%%" -L "%%RUNFROM%%\FILES\ROBOCOPY "%%FOLDER%%" "%%UWXPCD%%" *.* /E %%RS%%"Chad Link to comment Share on other sites More sharing options...
Fencer128 Posted September 15, 2005 Author Share Posted September 15, 2005 (edited) Hi Chad,Thanks for the info. Using the command line you supplied has 2 effects:1. The correct text is entered into the text file.2. The text is entered at the end of the file, rather than directly after the line referenced by the -A switch. I suspect this is to do with the way in which fedit parses "%%CD%%\FILES\ROBOCOPY "%%FOLDER%%" "%%UWXPCD%%" *.* /E %%RS%%" with the extra escape characters in it. Now, if the extra %s are removed then the command fails with a syntax error.I guess I still need to work on point 2.Thanks again,Andy Edited September 15, 2005 by Fencer128 Link to comment Share on other sites More sharing options...
cmarcusson Posted September 15, 2005 Share Posted September 15, 2005 (edited) I think it might be more likelly that the inner quotes are the problem.I'm curious what happens if you do this...echo exit| command /kPrompt -ADD -ONCE -F %BTS%\textfile.cmd -A %%CD%%\FILES\ROBOCOPY$S"%%FOLDER%%"$S"%%UWXPCD%%"$S*.*$S/E$S%%RS%% -L %%RUNFROM%%\FILES\ROBOCOPY$S"%%FOLDER%%"$S"%%UWXPCD%%"$S*.*$S/E$S%%RS%% | FEDITChad Edited September 15, 2005 by cmarcusson Link to comment Share on other sites More sharing options...
Fencer128 Posted September 15, 2005 Author Share Posted September 15, 2005 (edited) Hi Chad,I tried it and got:"The system cannot execute the specified program".I don't know if I've done something wrong or if the command line just won't work that way.Thanks again,AndyEDIT: Should have also said, not sure it's that important, but trying the first method you posted also resulted in the "" being missing from around %FOLDER% and "%UWXPCD% that were added to the bottom of the text file. Thanks. Edited September 15, 2005 by Fencer128 Link to comment Share on other sites More sharing options...
cmarcusson Posted September 15, 2005 Share Posted September 15, 2005 It just occured to me that the command tail length for this command is way too long. We max out at 127 Bytes after any given command, since the data is inserted at 0x81h and the program will start at 0x100h. I would venture to say that this particular approach is not going to work. There are other oossible alternatives methodes though.Chad Link to comment Share on other sites More sharing options...
Fencer128 Posted September 15, 2005 Author Share Posted September 15, 2005 Hi Chad,I think that with a little cunning and what you've developed so far, I may be able to get the job done anyhow. It might be just enough.Thank you for your time,Andy Link to comment Share on other sites More sharing options...
Fencer128 Posted September 15, 2005 Author Share Posted September 15, 2005 (edited) Hi,If I use this:FEDIT -ADD -ONCE -F %BTS%\BTS_DPs_auto.example.cmd -A "%%CD%%\FILES\ROBOCOPY \"%%FOLDER%%\" \"%%UWXPCD%%\" *.* /E %%RS%%" -L "%%RUNFROM%%\FILES\ROBOCOPY "%%FOLDER%%" "%%UWXPCD%%" *.* /E %%RS%%"and insert / before " then I can get the text placed in the correct place. The only small issue remaining now is if it is possible to keep the "" around the variables in the pasted text...EDIT:Escaping the " in the text to be pasted as is done above for the searched for text gets the job done 100%FEDIT -ADD -ONCE -F %BTS%\BTS_DPs_auto.example.cmd -A "%%CD%%\FILES\ROBOCOPY \"%%FOLDER%%\" \"%%UWXPCD%%\" *.* /E %%RS%%" -L "%%RUNFROM%%\FILES\ROBOCOPY \"%%FOLDER%%\" \"%%UWXPCD%%\" *.* /E %%RS%%"Solved! Cheers,Andy Edited September 15, 2005 by Fencer128 Link to comment Share on other sites More sharing options...
Fencer128 Posted September 16, 2005 Author Share Posted September 16, 2005 (edited) Mis-post. Sorry!Andy Edited September 16, 2005 by Fencer128 Link to comment Share on other sites More sharing options...
djbe Posted September 17, 2005 Share Posted September 17, 2005 I'm sorry I couldn't help earlier, I can't check the forums much anymore because of a vacation job. Glad you solved your problem. You may want to check the new fedit, wich works better, and has extra features Also, don't forget quotes around the filename (for if ever the file to be edited is in a dir with spaces in it's name):EDIT -ADD -ONCE -F "%BTS%\BTS_DPs_auto.example.cmd" -A "%%CD%%\FILES\ROBOCOPY \"%%FOLDER%%\" \"%%UWXPCD%%\" *.* /E %%RS%%" -L "%%RUNFROM%%\FILES\ROBOCOPY \"%%FOLDER%%\" \"%%UWXPCD%%\" *.* /E %%RS%%" Link to comment Share on other sites More sharing options...
Fencer128 Posted September 18, 2005 Author Share Posted September 18, 2005 Hi,Thanks for the reply. I'll be sure to grab the latest version of your fedit.Cheers and good luck with the job,Andy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now