Jump to content

How to run a simple console script unattended?


Recommended Posts

Hello, I am trying to run this script unattended, it works fine when logged in but not when not logged in. I know it has something to do with the console window and have also tried "ControlSend" commands but nothing works. I have run scripts like this before using batch files and those work, the thing that is different for me this time is console window is taking commands from the script.

The script runs a batch file which sends snmpget queries and populates a set of files, and then makes an insert statement into a database..

Thanks in advance for any help.

$i=0

While $i<10

$i=1

run("log.bat")

Sleep (5000)

$m1log1= FileRead ("m1log1.txt")

$m1log2= FileRead ("m1log2.txt")

$m1log3= FileRead ("m1log3.txt")

$m1log4= FileRead ("m1log4.txt")

$m1log5= FileRead ("m1log5.txt")

$m1log6= FileRead ("m1log6.txt")

$m2log1= FileRead ("m2log1.txt")

$m2log2= FileRead ("m2log2.txt")

$m2log3= FileRead ("m2log3.txt")

$m2log4= FileRead ("m2log4.txt")

$m2log5= FileRead ("m2log5.txt")

$m2log6= FileRead ("m2log6.txt")

;enter database

Run("db.bat")

Sleep (500)

Send ("{ENTER}")

sleep (15000)

;insert for m1

Send ("insert into LOG (datetime,modem,log1,log2,log3,log4,log5,log6) values (now(),'Det1&2','"&($m1log1)&"','"&($m1log2)&"','"&($m1log3)&"','"&($m1log4)&"','"&($m1log5)&"','"&($m1log6)&"');")

Send ("{ENTER}")

sleep (3000)

;insert for m2

Send ("insert into LOG (datetime,modem,log1,log2,log3,log4,log5,log6) values (now(),'Det3','"&($m2log1)&"','"&($m2log2)&"','"&($m2log3)&"','"&($m2log4)&"','"&($m2log5)&"','"&($m2log6)&"');")

Send ("{ENTER}")

sleep (3000)

;exit database

;Send ("exit")

;Send ("{ENTER}")

Winclose ("D:\nrl\cmd.exe")

sleep (60000)

wend

Note: the db.bat batch file logs into the database:

; mysql.exe -h 10.10.10.10 -u user -ppassword -D database

Link to comment
Share on other sites

Why don't you do everything (db.bat) in AutoIt? Then there would be no need to use Send.

AutoIt works fine with MySQL.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...