I have a bat file called "asbmon.bat that displays text "active." I
need to be able to run this program continuously and count the number
of times "active" is displayed. Is this something powershell can do?
Thanks,
--TJ
I have a bat file called "asbmon.bat that displays text "active." I
need to be able to run this program continuously and count the number
of times "active" is displayed. Is this something powershell can do?
Thanks,
--TJ
$count = 0
while ($true) {./asbmon.bat; $count++; $count}
would do what you want I think
--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk
"techjohnny@xxxxxx" wrote:
> I have a bat file called "asbmon.bat that displays text "active." I
> need to be able to run this program continuously and count the number
> of times "active" is displayed. Is this something powershell can do?
>
> Thanks,
>
> --TJ
>
Try something like this (use Ctrl-C to halt):
&{
while (1) {
cls
$i = 0
.\asbmon | % {if ($_ -match 'active') {$i++}}
"$i active"
sleep -m 250
}
}
--
Kiron
On Apr 18, 1:38 pm, "Kiron" <Ki...@xxxxxx> wrote:This is actually perfect. I would like to run this from a script, but
> Try something like this (use Ctrl-C to halt):
>
> &{
> while (1) {
> cls
> $i = 0
> .\asbmon | % {if ($_ -match 'active') {$i++}}
> "$i active"
> sleep -m 250
> }
>
> }
>
> --
> Kiron
when I copy-n-paste into text file and run it, it tries to open it
with notepad and doesn't execute script.
On Apr 18, 1:38 pm, "Kiron" <Ki...@xxxxxx> wrote:nevermind, just renamed it to .ps1
> Try something like this (use Ctrl-C to halt):
>
> &{
> while (1) {
> cls
> $i = 0
> .\asbmon | % {if ($_ -match 'active') {$i++}}
> "$i active"
> sleep -m 250
> }
>
> }
>
> --
> Kiron
On Apr 18, 3:08 pm, "techjoh...@xxxxxx" <techjoh...@xxxxxx>
wrote:How can I extend this to send an e-mail alert if the match number is
> On Apr 18, 1:38 pm, "Kiron" <Ki...@xxxxxx> wrote:
>>
> > Try something like this (use Ctrl-C to halt):>
> > &{
> > while (1) {
> > cls
> > $i = 0
> > .\asbmon | % {if ($_ -match 'active') {$i++}}
> > "$i active"
> > sleep -m 250
> > }>
> > }>
> > --
> > Kiron
> nevermind, just renamed it to .ps1
above 10?
Thanks,
--TJ
That's a whole 'nother thread, but there's a script on the repository
for sending email via SMTP ... it has a few extra things in it that
relate to gmail specifically, but it's here: http://powershellcentral.com/scripts/180
all you would need to do is, instead of the "$i active", do:
if($i -gt 10) {
Send-SmtpMessage "YOU@xxxxxx" "There are $i of them active!"
"Remember, don't get them wet! ... and lots of other useful
information can go here..."
}
On Apr 18, 9:44 pm, "Joel (Jaykul) Bennett" <Jay...@xxxxxx>
wrote:Perfect, but I'm using "Send-SmtpMail"
> That's a whole 'nother thread, but there's a script on the repository
> for sending email via SMTP ... it has a few extra things in it that
> relate to gmail specifically, but it's here:http://powershellcentral.com/scripts/180
>
> all you would need to do is, instead of the "$i active", do:
>
> if($i -gt 10) {
> Send-SmtpMessage "Y...@xxxxxx" "There are $i of them active!"
> "Remember, don't get them wet! ... and lots of other useful
> information can go here..."
>
> }
--TJ
On Apr 21, 9:35 am, "techjoh...@xxxxxx" <techjoh...@xxxxxx>
wrote:OK. The programming that runs this query request a password, I can
> On Apr 18, 9:44 pm, "Joel (Jaykul) Bennett" <Jay...@xxxxxx>
> wrote:
>>
> > That's a whole 'nother thread, but there's a script on the repository
> > for sending email via SMTP ... it has a few extra things in it that
> > relate to gmail specifically, but it's here:http://powershellcentral.com/scripts/180>
> > all you would need to do is, instead of the "$i active", do:>
> > if($i -gt 10) {
> > Send-SmtpMessage "Y...@xxxxxx" "There are $i of them active!"
> > "Remember, don't get them wet! ... and lots of other useful
> > information can go here...">
> > }
> Perfect, but I'm using "Send-SmtpMail"
>
> --TJ
specify the username from the command line, but it requires me to
enter the password, so how can I automate the input of the password
(which is probably not recommended, but need it)?
Thanks,
TJ
| Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Get-Help butchers words | Larry__Weiss | PowerShell | 5 | 14 Mar 2010 |
| for ... loop through file collection instead of for each ... loop | Ranah van Rijswijk | VB Script | 2 | 21 Feb 2010 |
| Search misses words that are in Outlook email | gahoman | Vista General | 3 | 31 Aug 2008 |
| search for words or phrases in vista | mabola2 | Vista file management | 1 | 17 Aug 2007 |
| Vista words update: No of words 69! | John Jay Smith | Vista General | 2 | 29 Jul 2006 |