🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.misc
Article #3542

Re: How to put CARRIAGE RETURN in Batch file

#3542
From: Kevin Lowey,159 Physics,(306) 96...
Date: Fri, 28 Jun 1991 14:47
59 lines
2387 bytes
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
Technical Details
Message-ID: <1991Jun28.144750.26681@herald.usask.ca>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!qt.cs.utexas.edu!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!unixg.ubc.ca!brazeau.ucs.ualberta.ca!alberta!herald.usask.ca!lowey
References: <3490@crdos1.crd.ge.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!qt.cs.utexas.edu!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!unixg.ubc.ca!brazeau.ucs.ualberta.ca!alberta!herald.usask.ca!lowey
From: lowey@herald.usask.ca (Kevin Lowey,159 Physics,(306) 966-4826,(306) 249-3232)
Newsgroups: comp.os.msdos.misc
Subject: Re: How to put CARRIAGE RETURN in Batch file
Message-ID: <1991Jun28.144750.26681@herald.usask.ca>
Date: 28 Jun 91 14:47:50 GMT
References: <3490@crdos1.crd.ge.COM>
Sender: lowey@herald.usask.ca (Kevin Lowey)
Reply-To: lowey@herald.usask.ca
Organization: University of Saskatchewan
Lines: 59