Batch file question

T

tcebob

This short batch file is supposed to take output from a telephone answering program,
append them to a text file and display the file in notepad until dismissed.

rem ; CallStation is configured to output Name, Number, Date & Time.
rem ; Script to intercept CallStation output, append to callnotif.txt and
rem ; open callnotif.txt.
@echo off
echo %1 %2 %3 %4 >> c:\program files\callstation\callnotif.txt
C:\WINDOWS\system32\notepad.exe c:\program files\callstation\callnotif.txt

Exercising it at the command line "callstation A B C D" fails. The script fails except the
file callnotif is opened in Notepad.

rs
 
N

NewScience

Everyone has write access to folder C:\progam files\callstation?
You append to the file, what about when the file doesn't exist, on the first
time?
 
T

tcebob

"Everyone" is me. I'll add frills after I can get the thing to work at all. Right now, it
opens notepad but fails to echo the parameters first.

Thanks for the suggestions

rs


: Everyone has write access to folder C:\progam files\callstation?
: You append to the file, what about when the file doesn't exist, on the first
: time?
:
: : > This short batch file is supposed to take output from a telephone
: > answering program,
: > append them to a text file and display the file in notepad until
: > dismissed.
: >
: > rem ; CallStation is configured to output Name, Number, Date & Time.
: > rem ; Script to intercept CallStation output, append to callnotif.txt and
: > rem ; open callnotif.txt.
: > @echo off
: > echo %1 %2 %3 %4 >> c:\program files\callstation\callnotif.txt
: > C:\WINDOWS\system32\notepad.exe c:\program files\callstation\callnotif.txt
: >
: > Exercising it at the command line "callstation A B C D" fails. The script
: > fails except the
: > file callnotif is opened in Notepad.
: >
: > rs
: >
: >
:
:
 
N

NewScience

Remember, command line scripts are still bound by DOS.

The 'echo' does not understand paths with spaces, notepad does.
Enclose the path on the echo line with quotes.
 
T

tcebob

Ok, I buy that. Now to wait for a call. . .

rs

: Remember, command line scripts are still bound by DOS.
:
: The 'echo' does not understand paths with spaces, notepad does.
: Enclose the path on the echo line with quotes.
:
: : > This short batch file is supposed to take output from a telephone
: > answering program,
: > append them to a text file and display the file in notepad until
: > dismissed.
: >
: > rem ; CallStation is configured to output Name, Number, Date & Time.
: > rem ; Script to intercept CallStation output, append to callnotif.txt and
: > rem ; open callnotif.txt.
: > @echo off
: > echo %1 %2 %3 %4 >> c:\program files\callstation\callnotif.txt
: > C:\WINDOWS\system32\notepad.exe c:\program files\callstation\callnotif.txt
: >
: > Exercising it at the command line "callstation A B C D" fails. The script
: > fails except the
: > file callnotif is opened in Notepad.
: >
: > rs
: >
: >
:
:
 
T

tcebob

You were right. It works splendidly. Except: each time it runs a new instance of notepad
is invoked along with a new cmd window. What I think I should do is enter a line at the
top to close notepad and save the file. But there doesn't seem to be that much control
available in the Batch system. I once subscribed to a magazine devoted to batch, which was
filled with unbelievable, impossible batch tricks. Some of it stuck but most slipped off.
Maybe this is a case for scripting?

rs


: Remember, command line scripts are still bound by DOS.
:
: The 'echo' does not understand paths with spaces, notepad does.
: Enclose the path on the echo line with quotes.
:
: : > This short batch file is supposed to take output from a telephone
: > answering program,
: > append them to a text file and display the file in notepad until
: > dismissed.
: >
: > rem ; CallStation is configured to output Name, Number, Date & Time.
: > rem ; Script to intercept CallStation output, append to callnotif.txt and
: > rem ; open callnotif.txt.
: > @echo off
: > echo %1 %2 %3 %4 >> c:\program files\callstation\callnotif.txt
: > C:\WINDOWS\system32\notepad.exe c:\program files\callstation\callnotif.txt
: >
: > Exercising it at the command line "callstation A B C D" fails. The script
: > fails except the
: > file callnotif is opened in Notepad.
: >
: > rs
: >
: >
:
:
 
S

Stan Brown

Tue, 15 Aug 2006 13:00:24 -0400 from NewScience <newscience83
@usadatanet.net>:
You append to the file, what about when the file doesn't exist, on the first
time?

Doesn't matter -- the file is created if it doesn't exist.

I rather suspect the issue is that the path\file needs to be in quote
marks since it contains a space.
 
S

Stan Brown

Except: each time it runs a new instance of notepad is invoked
along with a new cmd window. What I think I should do is enter a
line at the top to close notepad and save the file. But there
doesn't seem to be that much control available in the Batch system.
... Maybe this is a case for scripting?

I think it is.

My suggestion is AutoHotkey by Chris Mallett, a free program that I
love though I've only scratched the surface. Its IF command can
check, among other things, for whether there is already open a window
with a given title.

http://www.autohotkey.com

I've written quite a lot of batch programs, but some things can be
done only with scripts. After trying and discarding about half a
dozen programs, I read a suggestion at lifehacker.com for AutoHotkey,
and it's terrific.

For instance, at work I use it to open a particular Word document if
not already open, then launch a Word macro that's in that document
and paste various responses into the dialog box that the macro
presents.
 
T

tcebob

Oops. As you can note, above, I just downloaded
Autoit, which sounds similar. I'll give that a
spin and then maybe try AutoHotkey.

rs

message
: Wed, 16 Aug 2006 16:00:51 -0400 from tcebob
<handle @ gwi.net>:
: > Except: each time it runs a new instance of
notepad is invoked
: > along with a new cmd window. What I think I
should do is enter a
: > line at the top to close notepad and save the
file. But there
: > doesn't seem to be that much control available
in the Batch system.
: > ... Maybe this is a case for scripting?
:
: I think it is.
:
: My suggestion is AutoHotkey by Chris Mallett, a
free program that I
: love though I've only scratched the surface. Its
IF command can
: check, among other things, for whether there is
already open a window
: with a given title.
:
: http://www.autohotkey.com
:
: I've written quite a lot of batch programs, but
some things can be
: done only with scripts. After trying and
discarding about half a
: dozen programs, I read a suggestion at
lifehacker.com for AutoHotkey,
: and it's terrific.
:
: For instance, at work I use it to open a
particular Word document if
: not already open, then launch a Word macro
that's in that document
: and paste various responses into the dialog box
that the macro
: presents.
:
: --
: Stan Brown, Oak Road Systems, Tompkins County,
New York, USA
:
http://OakRoadSystems.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top