Merge 2 script variable problem

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
darioit
Posts: 230
Joined: 02 Aug 2010 05:25

Merge 2 script variable problem

#1 Post by darioit » 11 Oct 2014 00:55

Hello everybody,

I need to merge 2 script but I'm in big trouble with variable, I hope you give me right solution
Basically this 2 scripts access to same information "cc_debug.txt" at same time, so it's better merge it
I try to do it, but I can't solve problem of variable I also use a ! because of delay but doesn't work, 3 script it's my merge.
Thanks in advance and regards

First script

Code: Select all

echo off
setlocal enableDelayedExpansion
set /a record=-1
set /a FTPrecord=0
for /l %%# in () do (
  set /a "1/((record+=1)%%20)" 2>nul || (
   for /f "tokens=1-6 delims=/,.: " %%A in ("!date! !time: =0!") do (
      set "MenTime=<MenTime>%%A/%%B/%%C %%D:%%E:%%F</MenTime>"
      set "file_upd=C:\Meniscus\Ftp\ixwphysn_%%A%%B%%C_%%D%%E%%F"
      )
   set /a FTPrecord=!FTPrecord!+1
   if "!FTPrecord!"=="5" (
      move /Y C:\Meniscus\Ftp\* C:\Meniscus\Ftp\send\
      set /a FTPrecord=0
      SchTasks /Run /tn "\Current_Cost_cc128\FTP Meniscus"
      )
   )
   for /f %%A in ('tail -n1 C:\Meniscus\Data\cc_debug.txt') do (
   >>"!file_upd!" echo !MenTime!%%A
   )
   sleep 6
)


Second script

Code: Select all

@echo off
:start

for /F %%a in ('tail -n1 C:\Meniscus\Data\cc_debug.txt ^| find "<watts>"') do call set RIGA="%%a"
set TEMP=%RIGA:~71,4%
set WATT=%RIGA:~140,5%
"C:\Current_Cost_Dos\DB\rrdtool" update "C:\Current_Cost_Dos\DB\powertemp.rrd" N:%WATT%:%TEMP%
"C:\Current_Cost_Dos\DB\rrdtool" update "C:\Current_Cost_Dos\DB\power1temp1.rrd" N:%WATT%:%TEMP%

sleep 6
goto:start


third script

Code: Select all

echo off
setlocal enableDelayedExpansion
set /a record=-1
set /a FTPrecord=0
for /l %%# in () do (
  set /a "1/((record+=1)%%20)" 2>nul || (
   for /f "tokens=1-6 delims=/,.: " %%A in ("!date! !time: =0!") do (
      set "MenTime=<MenTime>%%A/%%B/%%C %%D:%%E:%%F</MenTime>"
      set "file_upd=C:\Meniscus\Ftp\ixwphysn_%%A%%B%%C_%%D%%E%%F"
      )
   set /a FTPrecord=!FTPrecord!+1
   if "!FTPrecord!"=="5" (
      move /Y C:\Meniscus\Ftp\* C:\Meniscus\Ftp\send\
      set /a FTPrecord=0
      SchTasks /Run /tn "\Current_Cost_cc128\FTP Meniscus"
      )
   )
   for /f %%A in ('tail -n1 C:\Meniscus\Data\cc_debug.txt') do (
   >>"!file_upd!" echo !MenTime!%%A

set RIGA="%%a"                        or set "RIGA=%%a"
set TEMP=%RIGA:~71,4%                 or set TEMP=!RIGA:~71,4!
set WATT=%RIGA:~140,5%                or set WATT=!RIGA:~140,5!
"C:\Current_Cost_Dos\DB\rrdtool" update "C:\Current_Cost_Dos\DB\powertemp.rrd" N:%WATT%:%TEMP%
"C:\Current_Cost_Dos\DB\rrdtool" update "C:\Current_Cost_Dos\DB\power1temp1.rrd" N:%WATT%:%TEMP%

   )
   sleep 6
)

Yury
Posts: 115
Joined: 28 Dec 2013 07:54

Re: Merge 2 script variable problem

#2 Post by Yury » 15 Oct 2014 11:16

Code: Select all

@echo off
setlocal enableDelayedExpansion
set /a record=-1
set /a FTPrecord=0
for /l %%# in () do (
  (set /a "var=1/((record+=1)%%20)" 2>nul&& set var)|| (
   for /f "tokens=1-6 delims=/,.: " %%A in ("!date! !time: =0!") do (
      set "MenTime=<MenTime>%%A/%%B/%%C %%D:%%E:%%F</MenTime>"
      set "file_upd=C:\Meniscus\Ftp\ixwphysn_%%A%%B%%C_%%D%%E%%F"
      )
   set /a FTPrecord=!FTPrecord!+1
   if "!FTPrecord!"=="5" (
      move /Y C:\Meniscus\Ftp\* C:\Meniscus\Ftp\send\
      set /a FTPrecord=0
      SchTasks /Run /tn "\Current_Cost_cc128\FTP Meniscus"
      )
   )
   for /f "delims=" %%A in ('tail -n1 C:\Meniscus\Data\cc_debug.txt') do (
   >>"!file_upd!" echo !MenTime!%%A
   set RIGA=%%A
   set TEMP=!RIGA:~71,4!
   set WATT=!RIGA:~140,5!
   "C:\Current_Cost_Dos\DB\rrdtool" update "C:\Current_Cost_Dos\DB\powertemp.rrd" N:!WATT!:!TEMP!
   "C:\Current_Cost_Dos\DB\rrdtool" update "C:\Current_Cost_Dos\DB\power1temp1.rrd" N:!WATT!:!TEMP!
   )
   sleep 6
)

darioit
Posts: 230
Joined: 02 Aug 2010 05:25

Re: Merge 2 script variable problem

#3 Post by darioit » 21 Oct 2014 01:46

nice work, thank you !

Post Reply