Jim Lawrence
accessd at shaw.ca
Mon Jul 20 00:11:13 CDT 2009
Hi Bobby: I have found a solution that works within a batch file. As long as the line of code is not within the first line or two of the batch file and the code is: for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set dt=%%k%%i%%j instead: for /F "tokens=2-4 delims=/ " %i in ('date /t') do set dt=%k%i%j It seems that the extra % percentage signs stops the code from falling apart... why; who knows. Jim -----Original Message----- From: dba-tech-bounces at databaseadvisors.com [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of Jim Lawrence Sent: Sunday, July 19, 2009 9:48 PM To: 'Discussion of Hardware and Software issues' Subject: Re: [dba-Tech] The Command prompt line length The batch file appears to actually be stripping of chunks of the code and then erroring out on half a line.... If I did not know better I would think it was a buffer over-flow but 'cmd' creates a buffer space of over 6000K. The 'for' command line actually loops internally, once for each parameter/token it extracts from the result of the 'date /t' command filling %k, %i and %j respectively. Then is it all reassembled into the 'dt' parameter. I have found numerous examples of similar pieces of code which are actually supposed to be working within a batch file and no commentary anywhere in Google, on a similar line of code failing. ...so there must be some simple reason for it failing. Jim -----Original Message----- From: dba-tech-bounces at databaseadvisors.com [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of Bobby Heid Sent: Sunday, July 19, 2009 8:55 PM To: 'Discussion of Hardware and Software issues' Subject: Re: [dba-Tech] The Command prompt line length Jim, That's a nice snippet. I do get an error from a batch file where it says: "kj was unexpected at this time" Where are the %k and %j variables being set? Thanks, Bobby -----Original Message----- From: dba-tech-bounces at databaseadvisors.com [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of Jim Lawrence Sent: Sunday, July 19, 2009 11:17 PM To: 'Discussion of Hardware and Software issues' Subject: Re: [dba-Tech] The Command prompt line length Thanks Bobby: If you want to see what the actual code does exchange the function 'set' for 'echo' Change: for /F "tokens=2-4 delims=/ " %i in ('date /t') do set dt=%k%i%j To: for /F "tokens=2-4 delims=/ " %i in ('date /t') do echo dt=%k%i%j or... for /F "tokens=2-4 delims=/ " %i in ('date /t') do echo %k%i%j Copy one of the above lines to the command lind and press enter. Next, to test the line of code in a batch file open up a notepad session, paste the line in and save it to some file like 'test.bat'; then try to run the batch file and see if it works. If it does not then you can see the same error as I am. Jim -----Original Message----- From: dba-tech-bounces at databaseadvisors.com [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of Bobby Heid Sent: Sunday, July 19, 2009 5:39 PM To: 'Discussion of Hardware and Software issues' Subject: Re: [dba-Tech] The Command prompt line length Jim. Is it possible that when the line is expanded internally that it is too long? I don't know where %i is pointing to, but my guess is that the folder that %i is pointing to is pretty long. Bobby -----Original Message----- From: dba-tech-bounces at databaseadvisors.com [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of Jim Lawrence Sent: Sunday, July 19, 2009 6:56 PM To: 'Discussion of Hardware and Software issues' Subject: [dba-Tech] The Command prompt line length Hi All: Has anyone heard of there being a limit of a line length within a batch file? I have a batch file that creates a directory and writes some backup data to it. This batch file works fine on other computers but on a specific computer the batch files fails on a longer line (64 characters). If the same line is run in direct mode no problem. The syntax is correct because if the line is cut and pasted to a command prompt the line functions correctly. The rest of the batch file runs fine without that one line... so it is related exclusively to the one line of code. Putting that one line of code into a batch file and then running it results in the same error. It appears that it is not buffering the whole line before attempting to run it. If anyone has run across this type of issues before and hopefully found a solution please pass it on. TIA Jim PS the cmd line of code is: for /F "tokens=2-4 delims=/ " %i in ('date /t') do set dt=%k%i%j _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com