If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > DOS or Batch Commands for Windows

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-29-06, 08:10
process process is offline
Registered User
 
Join Date: Jan 2005
Posts: 13
DOS or Batch Commands for Windows

Hi,

I am trying to automate a job which i require to do everyday. However, i encounter some problems. Hence, i would appreciate all fellow experts to shed some light.

Here i go.

Steps

1) Unzip a file
2) Search the contents of the file and extract the useful information and
dump them in a file.

Here are my codes.

if exist F:\home\weekly\Reports goto process
echo "No Mapped Drive Found"
echo "Please consult Administrator"
rocess
mkdir "c:\batch_test\reports"
F:
CD F:\home\weekly\Reports
find /c "101010102010491" view.txt

..continue........


Please do advice.

Thank you so much.

Regards.
Reply With Quote
  #2 (permalink)  
Old 08-31-06, 10:10
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
Hi, I presume you're familiar with shell scripting. I (want to) know very little of batch files, but for me the stuff written here http://www.die.net/doc/linux/abs-guide/dosbatch.html would be helpful...
Another way of doing some clever assembly in Windows is to use PERL, what can be obtained here: http://aspn.activestate.com/ASPN.

Regards
Reply With Quote
  #3 (permalink)  
Old 08-31-06, 16:19
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool


Or, just complete your script:
Code:
if exist F:\home\weekly\Reports goto process
  echo "No Mapped Drive Found"
  echo "Please consult Administrator"
  exit 1

:process
if NOT exist c:\batch_test\reports mkdir "c:\batch_test\reports"

F:
CD F:\home\weekly\Reports

REM To uncompress a file, you need the WinZip Command Line Support Add-On
REM I don't know the actual program name, but let's say it's: winzbat.exe
REM ...Uncompress file:

winzbat.exe -u view.txt.zip

REM ...Search for string and put results in other file:

find /c "101010102010491" view.txt >view_find_results.log



__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #4 (permalink)  
Old 08-31-06, 21:27
process process is offline
Registered User
 
Join Date: Jan 2005
Posts: 13
Smile

Quote:
Originally Posted by LKBrwn_DBA

Or, just complete your script:
Code:
if exist F:\home\weekly\Reports goto process
  echo "No Mapped Drive Found"
  echo "Please consult Administrator"
  exit 1

:process
if NOT exist c:\batch_test\reports mkdir "c:\batch_test\reports"

F:
CD F:\home\weekly\Reports

REM To uncompress a file, you need the WinZip Command Line Support Add-On
REM I don't know the actual program name, but let's say it's: winzbat.exe
REM ...Uncompress file:

winzbat.exe -u view.txt.zip

REM ...Search for string and put results in other file:

find /c "101010102010491" view.txt >view_find_results.log



Hi LKBrwn_DBA,

Thank you so much. Deeply appreciate it.
Reply With Quote
  #5 (permalink)  
Old 08-31-06, 22:11
process process is offline
Registered User
 
Join Date: Jan 2005
Posts: 13
Hi,

How do i make 2 sequential search using the find command?

find /c "101010102010491" "101010102010499" view.txt > view_find_results.log

Please advice.

Thank you.
Reply With Quote
  #6 (permalink)  
Old 09-01-06, 10:21
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,454
Quote:
Originally Posted by process
Hi,

How do i make 2 sequential search using the find command?

find /c "101010102010491" "101010102010499" view.txt > view_find_results.log
Code:
find /c "101010102010491" view.txt > view_find_results.log
find /c "101010102010499" view.txt >> view_find_results.log
For more elaborate stuff, I suggest using the Windows ports of GNU utilities, such as grep, awk, sed, and many others (look at gnuwin32.sourceforge.net).

You can also use the jar utility (freely available from java.sun.com) to work with .ZIP archives.
Reply With Quote
  #7 (permalink)  
Old 09-01-06, 10:22
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
Would something like:
Code:
find /c "101010102010491" view.txt > view_find_results.log
find /c "101010102010499" view.txt >> view_find_results.log
be fitting for your needs? And don't mind for the possible redundant lines in your logfile.
Seems to me you'd still be better off with a scripting language like PERL since with that you can do it all in once with a regular expression (and much, much more)...

Regards

Last edited by Tyveleyn; 09-01-06 at 10:27.
Reply With Quote
  #8 (permalink)  
Old 09-10-06, 10:58
process process is offline
Registered User
 
Join Date: Jan 2005
Posts: 13
Hi,

Besides the sequential search (find command), can i do a concurrent one using the find command?

Thanks.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On