[comp.os.msdos.misc] How to put CARRIAGE RETURN in Batch file

izslc19@disc.dla.mil (james cook) (06/24/91)

How can you put the Carriage Return in a batch file?  I download
files from the mainframe to the PC.  I would like to put those
commands into a batch file instead of typing the group of
commands every time I want to do that.  But each command requires
a carriage return at the end of every line.  How can I put a
carriage return in the batch file, execute the batch file, saving
me to type the entire procedure.

Thanks in advance.

Jim Cook
izslc19@disc.dla.mil  or  jcook@disc.dla.mil
Phila.,PA

izslc19@disc.dla.mil (james cook) (06/25/91)

From article <7130@disc.dla.mil>, by izslc19@disc.dla.mil (james cook):
> How can you put the Carriage Return in a batch file?  I download
> files from the mainframe to the PC.  I would like to put those
> commands into a batch file instead of typing the group of
> commands every time I want to do that.  But each command requires
> a carriage return at the end of every line.  How can I put a
> carriage return in the batch file, execute the batch file, saving
> me to type the entire procedure.
> 
> Thanks in advance.
> 
> Jim Cook
> izslc19@disc.dla.mil  or  jcook@disc.dla.mil
> Phila.,PA
> 
> 
 I should have mentioned in my original posting that I am downloading
 from a NAS mainframe (IBM compatible) to my PC using Telnet &
 FTP (File Transfer Program).

















-- 
--------------------------------------------
Jim Cook      (215) 697-0607     AV 442-0607 
izslc19@discg1.UUCP  or  izslc19@disc.dla.mil
Philadelphia, PA

doug@hparc0.HP.COM (Doug Parsons) (06/26/91)

I haven't tested this, but..

Create a file thus:

C:> COPY CON CR.      <-- copy from the console (kbd) to file called 'CR'.
		      <-- hit Enter here, which puts a <CR> character in file
Control-Z             <-- Press Control-Z here, to terminate input

(1) file copied.
C:>

What you have done is created a 2 character file consisting of a CR and a
control-Z (end of file marker).

Now you just have to use this as stdin (standard input, which is normally the
keyboard) when you want a carriage return:

myprog.exe < CR      <-pretend MYPROG normally asks for a CR before continuing.

Note that this doesn't work with PAUSE (well, it didn't work for me, anyway).
I hope that won't be a problem as the solution for PAUSE is to remove it!

BTW, I use this technique to get around the "Are you sure? (Y/N) :" when you
try to do a DEL *.*.  I have a file that contains a Y<CR>Control-Z, and do
this:
DEL *.* <Y           <-- The file is named "Y."

which works a treat in an autoexec.bat file when you want to clear all the
temp files left over from an aborted Windows/3 session! ie.
DEL C:\windows\temp\*.* <Y

douginoz

lsh@polari.UUCP (Lee Hauser) (06/26/91)

In article <7130@disc.dla.mil> izslc19@disc.dla.mil (james cook) writes:
>How can you put the Carriage Return in a batch file?  

Try Ctrl-M.  This is the ASCII code for CR-LF and works great whenever I use
it (for instance, I create a file called "Y.BAT" that consists of Y(CTRL-M)
which I redirect into batch files that erase directories and ask "are you
sure?").


-- 
------- ======= ------- ======= ------- ======= ------- ======= ------- =======
                  uw-beaver!sumax!polari!lsh -- lsh@polari
                                  Lee Hauser
          If I pay for access, I don't have to disclaim ANYTHING!

darcy@druid.uucp (D'Arcy J.M. Cain) (06/27/91)

In article <3060001@hparc0.HP.COM> Doug Parsons writes:
[ stuff deleted ]
>myprog.exe < CR      <-pretend MYPROG normally asks for a CR before continuing.
No need to create a file.  Try this:
echo. | myprog.exe

>Note that this doesn't work with PAUSE (well, it didn't work for me, anyway).
>I hope that won't be a problem as the solution for PAUSE is to remove it!
This doesn't work if you feed a batch file either but it does work if you
do "echo. | pause" but I can't see any real use for that.

>DEL *.* <Y           <-- The file is named "Y."
And this can be:
  echo Y | del *.*

The advantage to this system is you don't need a separate file for every
type of input and you don't have to assume the existence of the file or
know the path to it.

-- 
D'Arcy J.M. Cain (darcy@druid)     |
D'Arcy Cain Consulting             |   There's no government
Toronto, Ontario, Canada           |   like no government!
+1 416 424 2871                    |

userAKDU@mts.ucs.UAlberta.CA (Al Dunbar) (06/27/91)

In article <3060001@hparc0.HP.COM>, doug@hparc0.HP.COM (Doug Parsons) writes:
>I haven't tested this, but..
> 
>Create a file thus:
> 
>C:> COPY CON CR.      <-- copy from the console (kbd) to file called 'CR'.
>                      <-- hit Enter here, which puts a <CR> character in file
>Control-Z             <-- Press Control-Z here, to terminate input
> 
>(1) file copied.
>C:>
> 
>What you have done is created a 2 character file consisting of a CR and a
>control-Z (end of file marker).
> 
 
Funny, when I did this, my two character file contained a CR and
an LF instead of the ctl-Z.
 
 -------------------+-------------------------------------------
 Al Dunbar          | 
 Edmonton, Alberta  |  Disclaimer: "not much better than
 CANADA             |                  datclaimer"    
 -------------------+-------------------------------------------

davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) (06/27/91)

I think you mean you want to pass data to a running program from a batch
file, since every line in a batch file already ends with a CR. You can
do this by writing it to a file and then redirecting the input:

    @echo off
    rem autotransfer up to three files from a single host and directory
    rem (and mode), using ftp
    rem
    rem Usage: efteepee host dir mode file [ file [ file ]]
    rem
    echo cd %2 >ftp.tmp
    echo %3 >>ftp.tmp
    for %%n in (%4 %5 %6) do echo get %%n >>ftp.tmp
    echo quit >>ftp.tmp
    ftp %1 <ftp.tmp

I'm not a batch wizard, but this shows how to do what you want.

-- 
bill davidsen	(davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
  GE Corp R&D Center, Information Systems Operation, tech support group
  Moderator comp.binaries.ibm.pc and 386-users digest.

lowey@herald.usask.ca (Kevin Lowey,159 Physics,(306) 966-4826,(306) 249-3232) (06/28/91)

From article <3490@crdos1.crd.ge.COM>, by davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr):
> I think you mean you want to pass data to a running program from a batch
> file, since every line in a batch file already ends with a CR. You can
> do this by writing it to a file and then redirecting the input:
> 
>     @echo off
>     rem autotransfer up to three files from a single host and directory
>     rem (and mode), using ftp
>     rem
>     rem Usage: efteepee host dir mode file [ file [ file ]]
>     rem
>     echo cd %2 >ftp.tmp
>     echo %3 >>ftp.tmp
>     for %%n in (%4 %5 %6) do echo get %%n >>ftp.tmp
>     echo quit >>ftp.tmp
>     ftp %1 <ftp.tmp
> 
> I'm not a batch wizard, but this shows how to do what you want.

Here's a slightly improved version.  It checks to make sure that parameters
are given, and it uses the SHIFT command to handle all the parameters and
eliminate the restriction of only three files.

@echo off
rem autotransfer as many files as fit on the command line from a single host 
rem and directory (and mode), using ftp
rem
REM need at least 4 parameters
if "%4" == "" goto usage
REM the CD command
echo cd %2 >ftp.tmp
REM set the file mode
echo %3 >> ftp.tmp

REM Repeat for each file on the command line
:loop
  REM Get the file
  echo get %4 >> ftp.tmp
  REM shift everything over one position
  shift
  if not "%4" == "" goto loop
echo quit >>ftp.tmp
REM the following line works ONLY if FTP accepts input from STDIN
ftp %1 <ftp.tmp
goto end

:usage
  echo Usage: efteepee host dir mode file [ file [ file ]]

:end


One other note, if you want to echo ONLY a <CR>, you can do it with the command

ECHO.

Note there is NOT a space between the ECHO and the .

- Kevin Lowey