Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi all,
i need to write a batch file in win 2003 server machine which checks whether a file exist in a unix machine.
For example:
Honda is my windows machine. I need to right a batch file filecheck.bat which checks whether a file say test.txt exist in
Unix Machine : Juhu
Path : /u01/AUTOi need to check whether test.txt exist in /u01/AUTO directory in unix machine.
Please help me out as soon as possible...
thanks in advance
thanks
Arun S

If you can ftp to it try this:
::== juhu.bat
@echo off> ft.do echo o Juhu
>> ft.do echo username
>> ft.do echo password
>> ft.do echo bin
>> ft.do echo cd /u01/AUTO
>> ft.do echo dir test.txt
>> ft.do echo byeftp -s:ft.do | find "No such file or directory"
if errorlevel 1 echo test.txt is there
:: DONE
=====================================
If at first you don't succeed, you're about average.M2

i tried out...
a file by name ft.do is created and its content is as below.
o honda
wm
wm
bin
cd /u01/wmsqa/ftpdst
dir pass.txt
bye
i need to check whether file exist or not.some result has to written into a file or some kind of return value is required as result

You can change this:
if errorlevel 1 echo test.txt is there
to this:
if errorlevel 1 echo test.txt is there > log
=====================================
If at first you don't succeed, you're about average.M2

i tried this way. it writes the message test.txt file is there in log file. It also writes the same mes in log file eventhough file doesnt exist. and is it possible to pass these directory path and file name as command line argument. Please let me know the possible solution.
thansk in advance for you help.
thanks
Arun S

To use command line params, do something like:
set mydir=%1
and change this:
>> ft.do echo cd /u01/AUTO
to this:
>> ft.do echo cd %mydir%
######
As to your other questions, I'm not clear about what you are asking.
=====================================
If at first you don't succeed, you're about average.M2

may be my 2nd question is not clear. I want to check for file in unix or win. If it exists the bat file should give some message saying file exist. if file doesnt exist is should say file doesnt exist. or else it should some indication. As per ur suggestion i used if errorlevel 1 echo test.txt is there > file.log. Eventhough file doesnt exist it writes file exist in file.log file. proper info is not getting written in log file if file doesnt exist.
thanks for ur patience

Post your script.
=====================================
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |