Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Need Help in Batch File programming for automating a process ?

Status
Not open for further replies.

xpress_embedo

Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,154
Helped
161
Reputation
396
Reaction score
189
Trophy points
1,353
Location
India
Activity points
10,591
Hello!! Everyone, here is my batch file program, which lints my Embedded Project for errors:


Code Bash - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
echo off
set LINT_EXE=C:\lint\lint-nt.exe
set LINT_DIR=-i"C:\lint\lnt"
set PRJ_CFG="C:\data\Projects\General\lint\LintConfig.lnt"
set COMMAND=%LINT_EXE% %LINT_DIR% %PRJ_CFG%
set PRJ_PATH=C:\data\Projects\General\src
 
CALL :Seperator
echo Starting PC-Lint
CALL :Seperator
 
CALL :Seperator
 
%COMMAND% %PRJ_PATH%\base\main.c
 
CALL :Seperator
echo Press Any Key to Exit...
pause > nul
 
:Seperator
echo.
echo ###############################################################################
echo off
EXIT /B 0



I save it as "linting.bat"
And it works fine without any problem.

I open command prompt and type this command linting.bat and then all the messages are displayed on command prompt.
But now i want to save all the messages in a file, the one method is using this command linting.bat > filename.txt

But the PC-Lint has an option for this, i just have to change my COMMAND macro to

Code Bash - [expand]
1
2
set LOG="-os(log.txt)"
set COMMAND=%LINT_EXE% %LOG% %LINT_DIR% %PRJ_CFG%



So is there any method to interchange macro definition using command line option.
Means If
liniting.bat in command prompt then messages will get displayed to command prompt window
But if i type
linting.bat log then a log file also gets created.


Please suggest
 

there is a %1, %2 ....command parameter option for batch file.
read that and you can take diversion in your execution as you like.
 
Thanks, i am looking into this.

If possible can you post a simple example or any link.
Meanwhile i am searching at my end.
 

Had Done Like This:

Code Bash - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@echo off
set LINT_EXE=C:\lint\lint-nt.exe
set LINT_DIR=-i"C:\lint\lnt"
set LINT_LOG="-os(logging.txt)"
set PRJ_CFG="C:\data\Projects\General\lint\LintConfig.lnt"
set PRJ_PATH=C:\data\Projects\General\src
 
If "%1"=="-l" goto LOG_COMMAND
goto COMMAND
 
:LOG_COMMAND
echo.
echo LOGGING ENABLED (LOG WILL BE CREATED IN FILE LOGGING.TXT)
set COMMAND=%LINT_EXE% %LINT_LOG% %LINT_DIR% %PRJ_CFG%
goto MAIN
 
:COMMAND
set COMMAND=%LINT_EXE% %LINT_DIR% %PRJ_CFG%
goto MAIN
 
:MAIN
CALL :Seperator
echo Starting PC-Lint
CALL :Seperator



Then using command linting.bat -l to log and rest to display the content on Command Window.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top