Computing.Net > Forums > Windows Server 2003 > Batch file to check a file in Unix

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file to check a file in Unix

Reply to Message Icon

Name: arun_s010
Date: September 10, 2006 at 22:01:32 Pacific
OS: win 2003 server
CPU/Ram: 512mb
Product: dell
Comment:

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/AUTO

i 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



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: September 11, 2006 at 04:27:44 Pacific
Reply:

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 bye

ftp -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



0

Response Number 2
Name: arun_s010
Date: September 12, 2006 at 22:18:12 Pacific
Reply:

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


0

Response Number 3
Name: Mechanix2Go
Date: September 13, 2006 at 02:28:09 Pacific
Reply:

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



0

Response Number 4
Name: arun_s010
Date: September 18, 2006 at 02:10:32 Pacific
Reply:

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


0

Response Number 5
Name: Mechanix2Go
Date: September 18, 2006 at 04:26:10 Pacific
Reply:

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



0

Related Posts

See More



Response Number 6
Name: arun_s010
Date: September 20, 2006 at 22:26:50 Pacific
Reply:

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


0

Response Number 7
Name: Mechanix2Go
Date: September 21, 2006 at 03:36:07 Pacific
Reply:

Post your script.


=====================================
If at first you don't succeed, you're about average.

M2



0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Windows Server 2003 Forum Home


Sponsored links

Ads by Google


Results for: Batch file to check a file in Unix

Store Filename in Batch File www.computing.net/answers/windows-2003/store-filename-in-batch-file/7824.html

FTP in a batch file www.computing.net/answers/windows-2003/ftp-in-a-batch-file/7727.html

Trap in a batch file www.computing.net/answers/windows-2003/trap-in-a-batch-file/9540.html