|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
issue parsing a file...I have a very basic problem with which I could use advice as googling it gets me pieces of the answer by I don't know how to assemble them. Here's my problem, I have an installation script that is a batch file and is working, my issue is I need to search the last line in a particular .log file in the directory c:\tools on a workstation. In this last line in the log file, activity_3-23-09.log (current date), I need the script to start the installation citrix_install.bat when it find the value 'NA' after the second comma delimiter in the line. I need the script to be in a wait state until this value is written in the log, then to execute. ('NA' will be written when there is no user logged on.)
I am sooo lost on this. I think the answer is simple, but I just don't have the batch skills. Can anyone guide me through this? If so, please send the answer to cbw_1968@.... Thanks for looking... |
|
|
Re: issue parsing a file...On Mon, 23 Mar 2009 19:25:59 -0000, "Chris W." <cbw_1968@...> wrote:
>I have a very basic problem with which I could use advice as googling it gets me pieces of the answer by I don't know how to assemble them. Here's my problem, I have an installation script that is a batch file and is working, my issue is I need to search the last line in a particular .log file in the directory c:\tools on a workstation. In this last line in the log file, activity_3-23-09.log (current date), I need the script to start the installation citrix_install.bat when it find the value 'NA' after the second comma delimiter in the line. I need the script to be in a wait state until this value is written in the log, then to execute. ('NA' will be written when there is no user logged on.) > >I am sooo lost on this. I think the answer is simple, but I just don't have the batch skills. Can anyone guide me through this? If so, please send the answer to cbw_1968@.... If you ever come back here, these are the steps I would take. 1) locate the latest log file, using a for /f in-do command using the dir command with the /b switch and the /o switches to sort by date. The last file will be the one you want to use. 2) read the file line-by-line in another for /f in-do and saving each line in a variable - thus when the loop has completed the last line is in the variable. 3) Then use the find command to locate NA in the line. If it is not there then loop back to 1) and if it is there continue on to do whatever it is you wish to do. |
|
|
Re: issue parsing a file...--- In batchworld@..., foxidrive <foxidrive@...> wrote:
> > On Mon, 23 Mar 2009 19:25:59 -0000, "Chris W." <cbw_1968@...> wrote: > > >I have a very basic problem with which I could use advice as googling it gets me pieces of the answer by I don't know how to assemble them. Here's my problem, I have an installation script that is a batch file and is working, my issue is I need to search the last line in a particular .log file in the directory c:\tools on a workstation. In this last line in the log file, activity_3-23-09.log (current date), I need the script to start the installation citrix_install.bat when it find the value 'NA' after the second comma delimiter in the line. I need the script to be in a wait state until this value is written in the log, then to execute. ('NA' will be written when there is no user logged on.) > > > >I am sooo lost on this. I think the answer is simple, but I just don't have the batch skills. Can anyone guide me through this? If so, please send the answer to cbw_1968@... > > If you ever come back here, these are the steps I would take. > > 1) locate the latest log file, using a for /f in-do command using the dir > command with the /b switch and the /o switches to sort by date. The last > file will be the one you want to use. > > 2) read the file line-by-line in another for /f in-do and saving each line > in a variable - thus when the loop has completed the last line is in the > variable. > > 3) Then use the find command to locate NA in the line. If it is not there > then loop back to 1) and if it is there continue on to do whatever it is > you wish to do. > 1. for /f in i do dir /b /o "c:\tools\Activity*2009.log" 2. What command is the equivalent FSO in VB for reading a file line by line and going to the end of the file to look for the last instance of 'NA' after the second comma? |
|
|
Re: issue parsing a file...On Tue, 24 Mar 2009 15:01:11 -0000, "Chris W." <cbw_1968@...> wrote:
>--- In batchworld@..., foxidrive <foxidrive@...> wrote: >> >> On Mon, 23 Mar 2009 19:25:59 -0000, "Chris W." <cbw_1968@...> wrote: >> >> >I have a very basic problem with which I could use advice as googling it gets me pieces of the answer by I don't know how to assemble them. Here's my problem, I have an installation script that is a batch file and is working, my issue is I need to search the last line in a particular .log file in the directory c:\tools on a workstation. In this last line in the log file, activity_3-23-09.log (current date), I need the script to start the installation citrix_install.bat when it find the value 'NA' after the second comma delimiter in the line. I need the script to be in a wait state until this value is written in the log, then to execute. ('NA' will be written when there is no user logged on.) >> > >> >I am sooo lost on this. I think the answer is simple, but I just don't have the batch skills. Can anyone guide me through this? If so, please send the answer to cbw_1968@... >> >> If you ever come back here, these are the steps I would take. >> >> 1) locate the latest log file, using a for /f in-do command using the dir >> command with the /b switch and the /o switches to sort by date. The last >> file will be the one you want to use. >> >> 2) read the file line-by-line in another for /f in-do and saving each line >> in a variable - thus when the loop has completed the last line is in the >> variable. >> >> 3) Then use the find command to locate NA in the line. If it is not there >> then loop back to 1) and if it is there continue on to do whatever it is >> you wish to do. >> >so based on what you are saying: >1. for /f in i do dir /b /o "c:\tools\Activity*2009.log" >2. What command is the equivalent FSO in VB for reading a file line by line and going to the end of the file to look for the last instance of 'NA' after the second comma? This is untested: the find command looks for a litteral ,NA, and is case sensitive. You can also add a delay before the last line if you don't want to thrash the CPU. :) ping -n 60 127.0.0.1>nul will delay about 60 seconds. @echo off :loop for /f "delims=" %%a in ( 'dir "c:\tools\activity_*.log /b /od') do set "logfile=%%a" for /f "delims=" %%a in ("c:\tools\%logfile%") do set "lastline=%%a" echo "%lastline%"|find ",NA,">nul if errorlevel 1 goto :loop |
| Free embeddable forum powered by Nabble | Forum Help |