Sign in to follow this  
Followers 0
Provogeek

Command line arguments

8 posts in this topic

I want to use AutoIT to execute the Kiwi Syslog client tool to send messages to a syslog server that will first obtain the workstations name, then include what ever message I pass to it when I excute the script.

I am dealing with a 1200+ PC WAN that I need to get reports on everytime I deploy an update or application to the PC. I have bandwidth limits (160 stores, 256k each store to the data center) and I am being instructed to make any deployment as small as possible (and to make the transfer of knowledge as easy as possible since I am an intergrator and will not be around to maintain the system). The built in reporting included with the deployment software does not satisfy my customer and he has asked me to use Syslog since it provides him with a simple text file to work with (deployment software uses a Sybase database that he does not want to deal with).

The Kiwi syslog server can do resolution for the IP address to provide workstation name, but the WAN admin will not provide DNS updates fom DHCP since the IP address lease time is very small and workstations change their IP address many times through out the week (again, conserving bandwidth by not linking DHCP with DNS). To get an acurate report of what workstation has gotten what update/application, I am using AutoIT to grab the workstation name, then execute the Kiwi Syslog client placing the workstation name into the message it sends along with what ever it was that was acomplished.

I do not want to have to provide my customer with a script for every deployment to get a descriptive message to make the log viewing simplified and allow for cross deployments to occure. I would like to deploy a single script that I can simply call

Report.exe /m "Update KB012375 Complete"

And for the Syslog message to pop up on the server saying "0999WS02 Update KB012375 Complete"

then for the next deployment

Report.exe /m "Java 1.(what ever) installed"

And for the Syslog message to pop on the server saying "0999WS02 Java 1.(what ever) installed"

So that when ever I need to make a syslog message, I am not deploying the script every time, just executing and sending a command line argument to tell it what message I want it to pass along.

thank you

Share this post


Link to post
Share on other sites



I want to use AutoIT to execute the Kiwi Syslog client tool to send messages to a syslog server that will first obtain the workstations name, then include what ever message I pass to it when I excute the script.

I am dealing with a 1200+ PC WAN that I need to get reports on everytime I deploy an update or application to the PC. I have bandwidth limits (160 stores, 256k each store to the data center) and I am being instructed to make any deployment as small as possible (and to make the transfer of knowledge as easy as possible since I am an intergrator and will not be around to maintain the system). The built in reporting included with the deployment software does not satisfy my customer and he has asked me to use Syslog since it provides him with a simple text file to work with (deployment software uses a Sybase database that he does not want to deal with).

The Kiwi syslog server can do resolution for the IP address to provide workstation name, but the WAN admin will not provide DNS updates fom DHCP since the IP address lease time is very small and workstations change their IP address many times through out the week (again, conserving bandwidth by not linking DHCP with DNS). To get an acurate report of what workstation has gotten what update/application, I am using AutoIT to grab the workstation name, then execute the Kiwi Syslog client placing the workstation name into the message it sends along with what ever it was that was acomplished.

I do not want to have to provide my customer with a script for every deployment to get a descriptive message to make the log viewing simplified and allow for cross deployments to occure. I would like to deploy a single script that I can simply call

Report.exe /m "Update KB012375 Complete"

And for the Syslog message to pop up on the server saying "0999WS02 Update KB012375 Complete"

then for the next deployment

Report.exe /m "Java 1.(what ever) installed"

And for the Syslog message to pop on the server saying "0999WS02 Java 1.(what ever) installed"

So that when ever I need to make a syslog message, I am not deploying the script every time, just executing and sending a command line argument to tell it what message I want it to pass along.

thank you

Did you checkout the helpfile on Commandline parameters? Are you already comfortable with AutoIT arrays? If the answer to both is yes, you are home free. If not, please be more specific on what you need help with. The executive summary is that all the parameters passed to a script on the commandline are passed to the script via an array called $CmdLine, where the first element ($CmdLine[0]) contains the number of parameters and the following elements ($CmdLine[1] thru $CmdLine[n]) contain the acutal parameters.

:lmao:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Did you checkout the helpfile on Commandline parameters? Are you already comfortable with AutoIT arrays? If the answer to both is yes, you are home free. If not, please be more specific on what you need help with. The executive summary is that all the parameters passed to a script on the commandline are passed to the script via an array called $CmdLine, where the first element ($CmdLine[0]) contains the number of parameters and the following elements ($CmdLine[1] thru $CmdLine[n]) contain the acutal parameters.

:lmao:

Thank you PsaltyDS. When I searched the help file I did not find this when I was trying to figure out how to do this.

Now I just need to wrap my head around it.

thank you for the pointer.

Share this post


Link to post
Share on other sites

Well that was easier than I thought, just a single line too

RunWait("klogwin.exe -u <port> -h <ipaddress> -l 4 -F user -L notice -m " & '"' & @ComputerName & "  " & $CmdLineRaw & '"')

Does exactly what I was looking for, send the PC name along with what ever message I want taged after it.

thanks again PsaltyDS

Share this post


Link to post
Share on other sites

Now I just need to wrap my head around it.

thank you for the pointer.

here is an example how you could process the commandline parameters:

; retrieve commandline parameters
Dim $Batch = 0
Dim $install = 0
Dim $Server = ""
Dim $V_Arg = "Valid Arguments are:" & @LF
    $V_Arg &= "    /batch   - don't prompt for anything.. fail is something is missing." & @LF
    $V_Arg &= "    /install - Install the Client and Update Registry." & @LF
    $V_Arg &= "    /s NAME  - Target Server." & @LF
For $x = 1 to $CmdLine[0]
    Select
        Case $CmdLine[$x] = "/batch"
            $Batch = 1
        Case $CmdLine[$x] = "/install"
            $install = 1
        Case $CmdLine[$x] = "/s"
            $x = $x + 1
            $Server = $CmdLine[$x]
        Case Else
            MsgBox( 1, "Demo", "Wrong commandline argument: " & $CmdLine[$x] & @LF & $v_Arg)
            Exit
    EndSelect
Next

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Well that was easier than I thought, just a single line too

RunWait("klogwin.exe -u <port> -h <ipaddress> -l 4 -F user -L notice -m " & '"' & @ComputerName & "  " & $CmdLineRaw & '"')

Does exactly what I was looking for, send the PC name along with what ever message I want taged after it.

thanks again PsaltyDS

:ph34r:

:geek::):ph34r::)

DANGER! Danger, Will Robinson!!!

;):nuke::nuke::nuke:

$CmdLineRaw gives unreliable results, and is depricated in favor of the $CmdLine array. You may be introducing an unstable element to your script by doing it that way... :lmao:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

$CmdLineRaw gives unreliable results, and is depricated in favor of the $CmdLine array. You may be introducing an unstable element to your script by doing it that way... :lmao:

$CmdLineRaw was added later and wasn't depreciated in favor of....

4th Aug, 2004 - v3.0.102

Added: Predefined $CmdLineRaw variable now holds the original command line in full

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

$CmdLineRaw was added later and wasn't depreciated in favor of....

My mistake, bad use of a two-bit word: "deprecated". I'm not a programmer, so I wasn't supposed to be able to check that word out of the library anyway! :">

However, the point remains. Is $CmdLineRaw not considered much less reliable in use, because the results change based on how the script is run? I had a discussion on this before with MHz, and he schooled me on how the $CmdLine array was consistent, but the $CmdLineRaw was not. It appeared $CmdLineRaw was more of interest for debug use, and $CmdLine array should be used generaly.

:lmao:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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