Command Line/ CMD.exe not functioning correctly on a server

I am trying to excute a batch file on a Windows 2000 Server and get the following error:

D:\Oracle\oracledbsm\scripts>if exist c:\file.txt del c:\file.txt

D:\Oracle\oracledbsm\scripts>for /F %a in ('type c:\ips.txt') do (
echo ==== %a ====  1>>c:\file.txt
 ping %a  1>>c:\file.txt
)
'type c:\ips.txt' is not recognized as an internal or external command,
operable program or batch file.

Why does this batch file fail on this machine and work on all the others?

Thanks for any help.
TRAININGBSCAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michael PfisterCommented:
Why are you using "type"?

for /F %%a in (c:\ips.txt) do (
 echo ==== %a ====  1>>c:\file.txt
 ping %%a  1>>c:\file.txt
)

And note if you're putting this thing in a batch, you need to write %%a instead of %a.

Hope it helps,

Michael
0
Michael PfisterCommented:
Uups: missed one %a

for /F %%a in (c:\ips.txt) do (
 echo ==== %%a ====  1>>c:\file.txt
 ping %%a  1>>c:\file.txt
)
0
TRAININGBSCAuthor Commented:
The script is already that:

@echo on

if exist c:\file.txt del c:\file.txt
for /f %%a in ('type c:\ips.txt') do (
  echo ==== %%a ==== >>c:\file.txt
  ping %%a >>c:\file.txt
)
pause

Also, another script that fails is:

for /F "usebackq delims==" %%a in ('ydate -d "now + -1 days" +%%Y-%%m-%%d') do (
                if "%1"=="oracle" for /F "tokens=1-3 delims=-" %%d in ('echo %%a') do (
                        set today=%%d_%%e_%%f
                        set etoday=%%d%%e%%f


echo .

echo %%d

echo %%e
echo %%f

pause

OUTPUT IS

D:\Oracle\oracledbsm\appl>echo off
.
%d
%e
%f
Press any key to continue . . .
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Michael PfisterCommented:
Again, remove the "type" in the for-command and retry it:

@echo on

if exist c:\file.txt del c:\file.txt
for /f %%a in (c:\ips.txt) do (
  echo ==== %%a ==== >>c:\file.txt
  ping %%a >>c:\file.txt
)
pause

> Also, another script that fails is:

A bit hard to understand whats going on here. I don't know which output is generated by ydate. Again, no need to to use 'echo %%a' here, ist obsolete. Use

for /F "tokens=1-3 delims=-" %%d in ("%%a") do (

instead. The script might fail because 2 closing brackets ")" are missing at the end before or maybe after the pause command.
0
TRAININGBSCAuthor Commented:
why does type work straight from the cmd line, and not in the batch file?
0
Michael PfisterCommented:
"type" should work too, at least under XP it does work.
Still its not needed and seems to confuse Windows 2000.
Currently I have no access to a Windows 2000 machine to verify this.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 2000

From novice to tech pro — start learning today.