Sign in to follow this  
Followers 0
HankRausch

How to run a simple console script unattended?

4 posts in this topic

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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks, I have looked through the forum but have not found any relevant examples, can you direct me to any?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

When you are not logged on, any gui interaction function will fail including control send. A better way to go is through one of the database UDFs for direction manipulation. I think most of the popular DB's have UDF's.

Edited by DicatoroftheUSA

Share this post


Link to post
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
Sign in to follow this  
Followers 0