Page 1 of 1

Hey scripting gurus...

Posted: 08 Jun 2011 08:57
by allal
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.

Re: Hey scripting gurus...

Posted: 08 Jun 2011 09:20
by !k

Re: Hey scripting gurus...

Posted: 08 Jun 2011 11:20
by allal
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

Re: Hey scripting gurus...

Posted: 08 Jun 2011 11:38
by jeb
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

Re: Hey scripting gurus...

Posted: 08 Jun 2011 12:21
by allal
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

Re: Hey scripting gurus...

Posted: 08 Jun 2011 15:08
by Cleptography
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)

Re: Hey scripting gurus...

Posted: 08 Jun 2011 22:39
by dbenham
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

Re: Hey scripting gurus...

Posted: 08 Jun 2011 23:26
by Cleptography
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:

Re: Hey scripting gurus...

Posted: 09 Jun 2011 06:17
by allal
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