Hey scripting gurus...

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
allal
Posts: 34
Joined: 04 Jun 2011 05:49

Hey scripting gurus...

#1 Post by allal » 08 Jun 2011 08:57

please i really really need this output

how can i output two echo command in one line


how can i echo this code in one line

Code: Select all

echo this file & del /q file.txt && echo deleted successfuly.


output example

Code: Select all

this file deleted successfuly.

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Hey scripting gurus...

#2 Post by !k » 08 Jun 2011 09:20


allal
Posts: 34
Joined: 04 Jun 2011 05:49

Re: Hey scripting gurus...

#3 Post by allal » 08 Jun 2011 11:20

thanks it really works but when i run the below code the cmd window very fastly get resized and resized until the code ends
do you know why this resizing occur because there is no code that tells cmd to do such behevior,there is only echoing command

Code: Select all

@echo off
chdir /d "%~dp0"
set "scr=%~dp0\_cho.scr"
echo N _CHO.COM> "%scr%"
echo E 0100 BB 80 00 43 80 3F 0D 75 FA C6 07 24 B4 09 BA 82>> "%scr%"
echo E 0110 00 39 DA 7F 02 CD 21 B4 4C CD 21>> "%scr%"
for %%s in (RCX 001B W Q) do echo %%s>> "%scr%"
debug< "%scr%" >nul
del "%scr%" /q

_cho.com %date%
_cho.com . test first word
_cho.com . test second word.

pause >nul

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Hey scripting gurus...

#4 Post by jeb » 08 Jun 2011 11:38

allal wrote:thanks it really works but when i run the below code the cmd window very fastly get resized and resized until the code ends


The debug command resizes the window, perhaps also the _cho.com (didn't test this).

You can also use simple batch syntax to echo into the same line

Code: Select all

<nul set /p ".=Line1-"
echo This is appended to Line1


jeb

allal
Posts: 34
Joined: 04 Jun 2011 05:49

Re: Hey scripting gurus...

#5 Post by allal » 08 Jun 2011 12:21

jeb wrote:
allal wrote:thanks it really works but when i run the below code the cmd window very fastly get resized and resized until the code ends


The debug command resizes the window, perhaps also the _cho.com (didn't test this).

You can also use simple batch syntax to echo into the same line

Code: Select all

<nul set /p ".=Line1-"
echo This is appended to Line1


jeb



yes i use it to echo the dot ........but unfortunaty bad output

ok i use now powershell write-host -nonewline parameter it work fine without any trouble thanks powershell whether you like it jeb or not

ok ok ok jeb just kidding so don't get angry when i usually talk about powershell

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: Hey scripting gurus...

#6 Post by Cleptography » 08 Jun 2011 15:08

Powershell is better end of story period the end.
Maybe it is time for the dostips boyz to update their forums.
:arrow: DOS / CMD = :oops:
:arrow: PSHELL = 8)

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Hey scripting gurus...

#7 Post by dbenham » 08 Jun 2011 22:39

allal

It sounds like you are set with powershell. But there is an easy .bat solution known to this site that I'm surprised no one responded with. I think I learned this from a jeb post. I put a ping delay in to simulate some operation that takes time:

Code: Select all

@echo off
(<nul set/p=Hello )&(>nul ping 1.1.1.1 -n 1 -w 2000)&echo world!

result:

Code: Select all

Hello world!


If you want to make it more readable, you could define a simple "macro"

Code: Select all

@echo off
set "echoNoLF=<nul set/p="
(%echoNoLF%Hello )&(>nul ping 1.1.1.1 -n 1 -w 2000)&echo world!


Edit note: Wow - I didn't read jeb's answer carefully. He did post most of this solution already! Sorry for the oversight jeb. Jeb's version with quotes handles special characters witout escaping, but doesn't lend itself to a "macro". My version without quotes works as a simple "macro", but requires special characters to be escaped

Dave Benham
Last edited by dbenham on 09 Jun 2011 10:46, edited 1 time in total.

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: Hey scripting gurus...

#8 Post by Cleptography » 08 Jun 2011 23:26

bla bla bla dos bla bla bla batch bla bla bla cmd
dinosaur language for dinosaur folks.
It is not even a language hey look at me I script in batch
Hey look at me I just made a wheel, but wait is 2011
Thats ok I still made a wheel. Super neato man
Don't worry the ice age is coming soon to put you out of your misery.
Now Bob send me an email make me a gui and write me some web dialect
Oh I don't know that is a bit much.
Hello I'm a Mac, hi I'm a PC.
:roll:

allal
Posts: 34
Joined: 04 Jun 2011 05:49

Re: Hey scripting gurus...

#9 Post by allal » 09 Jun 2011 06:17

not bad
it is so complex than in any other language
but the code really worked

Code: Select all

@echo off
set "echoNoLF=<nul set/p="
set "pin=>nul ping 1.1.1.1 -n 1 -w 2000"

(%echoNoLF%No thanks )&(%pin%)&(%echoNoLF%No credit )&(%pin%)&(%echoNoLF% this )&(%pin%)&(%echoNoLF% dumb )&(%pin%)&(%echoNoLF% nature )&(%pin%)&(%echoNoLF% asks )&(%pin%)&(%echoNoLF% for )&(%pin%)&(%echoNoLF% nothing )&(%pin%)&echo in return
pause



thanks scripting gurus indeed

Post Reply