Page 1 of 1
How can I ECHO the currently executing command?
Posted: 07 Jul 2022 09:15
by BoQsc
Let's say. I want to ECHO (Display in the Command Prompt output) the:
but also execute it.
in the script:
Code: Select all
@ECHO OFF
ECHO This is some example.
some_file.exe -flags arguments REM I want this to be shown in the output on the command line. And also execute it.
PAUSE
EXIT
Re: How can I ECHO the currently executing command?
Posted: 07 Jul 2022 10:20
by aGerman
Set the prompt empty. Then turn echo on to repeat the executed command line.
Code: Select all
@ECHO OFF
ECHO This is some example.
prompt $H
echo on
some_file.exe -flags arguments
@echo off
PAUSE
Steffen
Re: How can I ECHO the currently executing command?
Posted: 07 Jul 2022 11:06
by BoQsc
aGerman wrote: ↑07 Jul 2022 10:20
Set the prompt empty. Then turn echo on to repeat the executed command line.
Code: Select all
@ECHO OFF
ECHO This is some example.
prompt $H
echo on
some_file.exe -flags arguments
@echo off
PAUSE
Steffen
This introduces the unnecessary empty line in-between.
Code: Select all
This is some example.
notepad.exe -flags arguments
Press any key to continue . . .
Re: How can I ECHO the currently executing command?
Posted: 07 Jul 2022 11:13
by aGerman
I didn't expect that this is much of a problem ¯\_(ツ)_/¯ If the empty line is something you can't accept, then you have to repeat the command line yourself using ECHO. Like so ...
Code: Select all
echo some_file.exe -flags arguments
some_file.exe -flags arguments
Steffen
Re: How can I ECHO the currently executing command?
Posted: 07 Jul 2022 11:56
by BoQsc
aGerman wrote: ↑07 Jul 2022 11:13
I didn't expect that this is much of a problem ¯\_(ツ)_/¯ If the empty line is something you can't accept, then you have to repeat the command line yourself using ECHO. Like so ...
Code: Select all
echo some_file.exe -flags arguments
some_file.exe -flags arguments
Steffen
I was pretty sure that there was a cleaner way of achieving this.
I think I've remember some piping to the ECHO command or something like that.
The results was pretty good: easily readable and simple. No additional troubles.
Thing is, the arguments and flags can change.
From the response, I think I see that I might need to start a new project to improve upon and replace the Batch scripting language.
Re: How can I ECHO the currently executing command?
Posted: 07 Jul 2022 11:59
by miskox
Re: How can I ECHO the currently executing command?
Posted: 07 Jul 2022 12:04
by BoQsc
I'm not completely new to the language, only a bit rusty.
Re: How can I ECHO the currently executing command?
Posted: 07 Jul 2022 12:32
by aGerman
What about a subroutine geting the command line passed?
Code: Select all
@ECHO OFF
ECHO This is some example.
call :repeatAndExec some_file.exe -flags arguments
PAUSE
goto :eof
:repeatAndExec
echo %*
%*
goto :eof
Steffen
Re: How can I ECHO the currently executing command?
Posted: 07 Jul 2022 13:22
by BoQsc
aGerman wrote: ↑07 Jul 2022 12:32
What about a subroutine geting the command line passed?
Code: Select all
@ECHO OFF
ECHO This is some example.
call :repeatAndExec some_file.exe -flags arguments
PAUSE
goto :eof
:repeatAndExec
echo %*
%*
goto :eof
Steffen
I mean yeah, it's good enough, haven't encountered any inconsistencies in my own adaptations.