[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2006-04-26
8
Medium Priority
?
127 Views
Last Modified: 2010-04-13
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.
0
Comment
Question by:TRAININGBSC
  • 4
  • 2
6 Comments
 
LVL 29

Expert Comment

by:Michael Pfister
ID: 16541993
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
 
LVL 29

Expert Comment

by:Michael Pfister
ID: 16541996
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
 

Author Comment

by:TRAININGBSC
ID: 16542014
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 29

Expert Comment

by:Michael Pfister
ID: 16542100
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
 

Author Comment

by:TRAININGBSC
ID: 16542262
why does type work straight from the cmd line, and not in the batch file?
0
 
LVL 29

Accepted Solution

by:
Michael Pfister earned 500 total points
ID: 16542416
"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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
LinkedIn blogging is great for networking, building up an audience, and expanding your influence as well. However, if you want to achieve these results, you need to work really hard to make your post worth liking and sharing. Here are 4 tips that ca…
Loops Section Overview
Screencast - Getting to Know the Pipeline
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question