How to omit the EOF indicator?

Noble security Dell optilex mini tower c...
March 5, 2010 at 00:54:47
Specs: Windows XP

I would like to ask if someone knows how to omit the EOF indicator () inside the file when I download it from the AS400 using FTP on batch file programming.

Appreciate your help!

See More: How to omit the EOF indicator?

Report •

March 5, 2010 at 01:09:26
FTP does not do other manipulations than End-of-line handling ... if you need to modify file content, either do it on the source already (if that is an option), or (more likely) just FTP them over and then change the content.

Show us such a file.

Report •

March 5, 2010 at 01:17:08
Thanks for the reply. I'm not really good in batch file programming that's why i ask that question. :)
i'm just doing this to automate the extraction of data from the AS400. the data were rejected because of the EOF indicator. with that, I thought there was a command in Batch File Programming that could omit or delete that special character.
THanks again!

Report •

March 5, 2010 at 01:19:01
I think your post got mangled by the forum.

Is it a text file? Is the EOF 1a hex?

How big is the file?

Helping others achieve escape felicity


Report •

Related Solutions

March 5, 2010 at 01:24:07
its a small text file.
this is the command that i used to extract the data:

get XEXTR01F.dat extr01f.dat

It's just a simple GET command.

after extracting that document, there is a special character on the bottom of the file

Report •

March 5, 2010 at 05:58:40
i wrote this for myself to allow replacement of hex data in files.
(replacement only, not insert or delete).
if you call this repl.bat, then usage would be:
repl filename x1 x2
f/e, like: repl testing.txt 1a 0a
to replace char. 26 with char.10, for example.
max size limit is whatever debug will read, 64K i think.
:: DEBUG-driven simple char. repalcement tool
@echo off & setlocal enabledelayedexpansion
set yy=0
set xx=%2
call :two
set dd=%cc%
set cc=
set xx=%3
set yy=0
call :two
:: size is in decimal, i know it's wrong, just using for approx.
for %%a in (%1) do set sz=%%~za
::echo %sz%
> deb echo s100,%sz%,%dd%
>> deb echo q
debug %1 < deb > deb2
del deb
for /f "skip=1 tokens=1* delims=:" %%a in (deb2) do (
if "%%b" equ "" goto :nex
>> deb echo e%%b %cc%
>> deb echo w
>> deb echo q
echo ready? ready to RIP!
debug %1<deb >nul
goto :eof

set aa=!xx:~%yy%,2!
set /a yy+=2
if "%aa%" equ "" goto :eof
set cc=%cc% %aa%
goto :two

set /a aa/=2
echo %aa%

Report •

March 5, 2010 at 06:41:19
here's a shorter version that just lops off the last 'n' bytes from a given file (usage: tail filename 3):
:: tail.bat, usage: TAIL filename N to trunc N bytes off end of file

@goto :aa


@echo off & setlocal
debug %1<%0.bat>deb
for /f "tokens=2" %%a in (deb) do set xx=%%a
echo h %xx% %2
>deb echo h %xx% %2
>> deb echo q
debug<deb > deb2
for /f "tokens=2" %%a in (deb2) do set xx=%%a
> deb echo rcx
>> deb echo %xx%
>> deb echo w
>> deb echo q
debug %1<deb

Report •

March 5, 2010 at 06:52:32
Why to build a nuclear power plant to get some warm water?

Save the following as X1A.bat and at prompt type

x1a Your_File_Name

:: X1A.BAT Usage: x1a [PathName]FileName
@echo off & setlocal EnableDelayedExpansion

type nul > "%~dpn1.tmp"
set flag=ON
for /F "delims="  %%j in ('type "%~f1"') do (
 if not defined flag echo.!row!>> "%~dpn1.tmp"
 (set flag=)
 set row=%%j
del "%~f1"
ren "%~dpn1.tmp" "%~nx1"
:: End_Of_Batch

Report •

March 5, 2010 at 09:04:06
IVO is my hero.

Helping others achieve escape felicity


Report •

March 5, 2010 at 13:53:51
but isn't it an assumption that the eof is on a line by itself? what if it's appended on the end of a line that has data?

Report •

March 5, 2010 at 14:50:40

you are right, however a true text file collects strings ended by CR/LF. If the EOF is appended at the end of the file, it creates a line holding just 1Ah (i.e. CR/LF.....CR/LF-1Ah).

Anyway the OP is the one that can give the answer.

Report •

March 5, 2010 at 15:10:13
yes, that is a reasonable assumption, esp. since the file is generated by fairly standard computing environment.
after i finally figured out what you were doing, i also thought of providing insurance:
@echo off>tmp & setlocal enabledelayedexpansion
for /f "usebackq delims=" %%a in ("%1") do
if defined row >> tmp echo !row!
set row=%%a
>>tmp echo !row:~0,-1!
:: -------- end

i could not get my head straight how a var. could be "not defined" and yet have a value at the same time. I sort of figured it out, having to do with being inside the for-loop and the delayed expansion issue. I'm still kind of confused.. i had to run yours a few times to see what it was doing.
Also, weird: the first time i ran it, i used the batchfile itself as the test subject, and it inserted line 6 in the middle of line 7!
(ie: X1A X1A.BAT):
output looked like this:

:: X1A.BAT Usage: x1a [PathName]FileName
@echo off & setlocal EnableDelayedExpansion
echo output to %~dpn1.tmp
type nul > "%~dpn1.tmp"
set flag=ON
for /F "delims=" %%j in ('type "%~f1"') do (
if not defined flag echo.for /F "delims=" %%j in ('type "%~f1"') do (>> "%~dpn1.tmp"
(set flag=)
set row=%%j
:del "%~f1"
:ren "%~dpn1.tmp" "%~nx1"
:: End_Of_Batch

i forgot about ">>" in datastream causing echo to act weird

------------ never considered using the copy that
way. Never would have thought of that. Cool!

Report •

March 5, 2010 at 17:26:56
A couple of points:

1. Doesn't your AS/400 use EBCDIC encoding rather than
ASCII? If so, then you've got more serious problems than just
an EOF character.

2. If the problem is just an EOF character, this command will
remove it:

COPY oldfile /A newfile /B

Report •

March 5, 2010 at 17:44:23
Hi klint,

I thought there was a way with copy, but my mind was in extra senior mode.

Helping others achieve escape felicity


Report •

March 6, 2010 at 03:49:21

Cheers, I was aware the copy command can do the job coding the right switches, but I missed the correct blend.

About EBCDIC under AS/400 environment, when I operated IBM MVS mainframes, the FTP to Windows/Unix environments provided the ASCII conversion of downloaded code. I hope the OP gives us any feedback instead of vanishing as usual.


A "not defined" variable is one set to null value because never defined or reset by a set var= command.

Report •

March 6, 2010 at 06:40:16
@IVO: yeah, but when i was testing the script, i got this weirdness (added lots of tests, simplifying loop):
set flag=OK
for /L %%a in (1 1 3) do (
if defined flag echo.defined flag:[%flag%]
set flag=
if defined flag (
echo flag defined:[%flag%]
) else (
echo flag not defined:[%flag%]
if "%flag%" neq "" (
echo.not null flag[%flag%]
) else (
echo.null flag[%flag%]
set row=%%j

flag not defined:ON
not null flag[ON]

2nd test was ok, flag was not null, it was "ON".
1st test, "if defined" is what has me confused, as the variable is show simultaneously as "ON" and "not defined".
can you explain why this is?

Report •

March 7, 2010 at 03:38:25

In your script you access a variable that is modified inside a "block sequence", i.e. a set of statements embraced by parenthesis.
A block sequence occurs when you code

  for... do (...)
  if... (...) else (...)
or just
  (a sequence of statements...)

In the cases reported above you need to enable the "Delayed Expansion" and then mark your values with the ! symbol.

The correct version of your script is

@echo off & setlocal EnableDelayedExpansion
set flag=OK
for /L %%a in (1 1 3) do (
  if defined flag echo.defined flag:[!flag!]
  (set flag=)
  if defined flag (
    echo.flag defined:[!flag!]
  ) else (
    echo.flag not defined:[!flag!]
  if  not "!flag!"=="" (
    echo.not null flag[!flag!]
  ) else (
    echo.null flag[!flag!]
  set row=%%j

Notice that when resetting a variable it is better to embrace the statement with () to avoid unwanted trailing spaces that could nullify the reset. When the delayed expansion is enabled you can still use the static notation % for variables accessed outside block sequences, but to avoid confusion it is better to mark all values with the ! symbol.

I hope my explanation is understandable.

Report •

March 7, 2010 at 09:44:57
thanks IVO, that did clarify where i muddied things up!
I knew about the % vs ! but didn't associate them correctly in my tests. my confusion arose from which "flag" is referred to by the IF DEFINED statement, and it is the !flag! and not the %flag% (ie, in essence there are two flags, and i got mixed up about which one is referencened in the defined stmt)
thanks for helping me figure it out.

Report •

Ask Question