Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dos bat file to telnet unix machine

Status
Not open for further replies.

muralisai25

IS-IT--Management
Jul 20, 2002
51
0
0
US
Hi,
I would like to write a DOS batch file that will telnet to a UNIX machine and go to a certain folder and count the number of files of certain format and save the TOTAL COUNT in a file and send that file back to the PC and delete the count file we created from UNIX folder.

I know how to telnet to unix and thats about it. I am not a unix person. There is a catch... The folder name in unix is something like this. /temp/YYMMDD... the folder YYMMDD is the current date when the connection is made to the unix machine... Then i need to count the number of *.HTML files in that folder and save the count in a file and FTP'ed back to my PC.... Does anyone know how to write the unix script or commands in the batch file that wud let me CHECk a folder in UNIX and count the number of files in that folder and send it back to my PC as a text file.
Any help on this would be appreciated.
 
OK ITS me again, I wanted to add more to my post may be that will help... I was reading a UNIX book and i saw someting about a cron JOB.... Is there a way i can write a script to go to a folder count the number of files and output the data to a NEW file in the same folder.

Again the scenario is.... At certain time of the day, a program creates a folder in the UNIX directory... the folder is created with the current dates name..for example if the current date was July 28th...the folder has the name 072802 and then there is a whole bunch of HTML files in it.. WHat i was originally trying to do was.... Telnet to this unix machine from my PC and get the file that is going to have a total count of all the files in that Particular (072802) folder..... Any help wud be appreciated.
 
You can run a script from cron that can send you an email.
I am not sure exactly what you want.

But if you just want a count of the html files everyday in
a directory to be emailed to you. Try this


ls /tmp/`date +%m%d%y`/*.html | wc -l | mail you@domain.name

 
Hi Boy,
Thanks for ur suggestion. I will try this as well...
BUt is there a way i can send this to a FILE??? I mean count the number of html files and then print the count in a flat file. What i am trying to accomplish is this... SInce i am new to unix...and not getting any help from the unix guys...

I have a DOS batch *.bat file that is doing a telnet/ftp to a unix server. It goes in to a certain folder and then get a file from that folder. The file i am trying to get is the flat file that has a total count of all HTML files created by the cron JOB...

Can u please tell me... how to save this script that U suggested as a executable file and then SETUP a cron job... again i am not a unix person...
Thankx for ur help in advance.
 
HI one more question. I just found out the folder name is of the format YYYY-MM-DD how can i do a LS on a folder with the date format like 2002-07-31???? I trie ur example and i can also use slashes, can u please tell me how to do this..an example wud be helpful.
Thankx again
 
Hi,
I also have the same need to get files from Unix back to DOS through ftp. Can you kindly send me your DOS bat file?
Thanks a lot.
xiaodan_zhu@hotmail.com
Mike
 
to get the date in the format YYYY-MM-DD:

date '+%Y-%m-%d'
 
The count of the number of files can be written to a flat file by redirecting the output of the wc -l command
i.e something like
wc -l >/mydir_my_filename

amit
crazy_indian@lycos.com

to bug is human to debug devine
 
Hello, Muralisai25... could u send me your batch file in DOS,I'm trying to do the same,,

But I need to do it from my PC,cause I'm not allowed to run an Unix script on the server,,

thanks,

PD. I think your question can be resolved using the redirection pipe "|" to do your job...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top