Jump to content
wisem2540

Trying to send firmware to a list of zebras maybe using netcat

Recommended Posts

wisem2540

This isnt really an autoit question, but I know people on this forum have done this before.  See: https://www.autoitscript.com/forum/topic/156364-netcat-to-send-zpl-files-to-zebra-printers/

I cannot get this to even remotely try to work.  Perhaps I have the wrong version of Netcat?  Can someone point me in the direction of a working version of NC.  Has anyone successfully automated anything like this?

Share this post


Link to post
Share on other sites
computergroove

http://osxdaily.com/2014/03/27/send-data-across-network-netcat/

Try sending a file to one of the computers after you have configured it to see if it worked. You should be able to do what you want after that. Unless you want to update the firmware on a regular basis I think the configuration on all the terminals will take longer than just modifying the firmware manually. You could also just remote into the terminals with remote access and run the upgrade. Autoit could automate this if its a huge job.


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
wisem2540

I have figured out how to do this...

For anyone interested, Zebras respond to LPR commands.  Now, LPR is not enabled by default on WIndows 7, so youll hav.  to do that.

Basically, it works like this..   On my particular zebra, I had to use LPR via command line to enable FTP execute on the printer.  Then I used the FTPex.au3 functions to FTP the file up to the printer.  With FTP execute on, the firmware installs automatically. :)

The code is not commented, but what you will see is that it uses Inetgetsource to read the firmware version of the printer.  And if its out of date, it updates.  If not the it writes it to a COMPLETE file.  After the update, it waits for a while for the printer to reboot, the uses Inetgetsource again to read the webpage of the printer and verify that the update was successful.  The whole routine is put into an infinite WHILE loop and continues cycling through everything that is found to be OFFLINE. So far, I started with 741 printers, and have 170 to go.  As these printers come online, the script will eventually get them all. Youll see at the end that if it finds end.txt that the while loop will exit.  This is put in so that I can make manual modifications to the list after a full loop.  I just create the file if I need to stop the process.  And if I need to stop immediately, I have set a hotkey.  I know, in the end, this routine is not autoit specific, but I came here looking for a way to do this, so if this helps one person, then I am happy. 

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.12.0
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

 #include <FTPEx.au3>
 #include <Inet.au3>
#include <array.au3>
#include <File.au3>


local $IPs2
Global $IPs
Global $version
Global $log = @ScriptDir & "\autoftp.log"
Global $loop = 0
_FileWriteLog ($log, "Starting")
HotKeySet("{Esc}", "close")

while 1
If FileExists (@Scriptdir & "\offline.txt") Then
   FileMove (@Scriptdir & "\offline.txt",@Scriptdir & "\work.txt",1)
EndIf

_FileReadToArray (@ScriptDir & "\work.txt",$IPs2,0)
;_ArrayDisplay($IPs2)
_ArraySort ($IPs2)

$IPs = _ArrayUnique ($IPs2,0,0,0,1)
_FileWriteLog ($log, $IPs[0] & " Items left")
;_ArrayDisplay ($Ips)

For $x = 1 to $IPs[0]
    $version = "Nothing"

SplashTextOn ("", "Working on " & $x & " of " & $IPs[0],300,50,-1,-1,1); shows text

Ping ($IPs[$x])
If @error Then
   FileWriteLine (@Scriptdir & "\offline.txt",$IPs[$x])
   ContinueLoop
   Else

$s = _INetGetSource ("http://" & $IPs[$x], True)
_FileWriteLog ($log, "Getting Source from " & $IPs[$x])
EndIf

if $s = "" Then
$version = "Offlline"
FileWriteLine (@Scriptdir & "\onlinepagedown.txt",$IPs[$x])
;FileWriteLine ("H:\results.csv",$IPs[$x] & "," & $version)
_FileWriteLog ($log, "Web Server Down")
ContinueLoop
EndIf

$Array = StringRegExp ($s,"(V......\d..)",3)
If IsArray ($Array) Then
    If StringRight ($Array[0],1) = "<" Then $Array[0] = StringTrimRight($Array[0],1)
    $version = $Array[0]
Else
    $version = "NotFound"
 EndIf

If $version = "V68.19.10z" Then
_FileWriteLog ($log, "Version is Up To Date")
FileWriteLine (@Scriptdir & "\updated.txt",$IPs[$x])
ContinueLoop
EndIf

_FileWriteLog ($log, "Version is " & $version & " Updating")

_FileWriteLog ($log, "Setting FTP Execution to ON")
RunWait (@ComSpec & " /c lpr.exe -S " & $IPs[$x] & " -P zebra C:\users\afm1191\desktop\test.txt")
_FileWriteLog ($log, "Done")

$Ftp = _FTP_Open ("myftp")
$session = _FTP_Connect ($Ftp,$IPs[$x],"admin","zebra")
_FileWriteLog ($log, "Uploading File")
$FTP_PF = _FTP_FilePut($session, "C:\v68.19.10z.zpl", "v68.19.10z.zpl" )
If $FTP_PF = 0 Then
_FileWriteLog ($log, "FTP Upload FAILED")
FileWriteLine (@Scriptdir & "\uploadfailed.txt",$IPs[$x])
ContinueLoop
Else
   _FileWriteLog ($log, "FTP Upload SUCCESS")
EndIf
_FTP_Close($ftp)
_FileWriteLog ($log, "Closing Connection")
_FileWriteLog ($log, "Waiting for Zebra to come online")
Sleep (10000)

While 1
If $loop > 18 Then
 _FileWriteLog ($log, "Zebra Reboot FAILED")
 ExitLoop
 EndIf
Ping ($IPs[$x])
If @error Then
Sleep (30000); wait 30 seconds, then loop again
  $Loop = $Loop + 1
   Else
      _FileWriteLog ($log, "Zebra is back online")
      $Loop = 0
      ExitLoop
   EndIf
   WEnd

   If $loop > 18 Then
   FileWriteLine (@Scriptdir & "\failedreboot.txt",$IPs[$x])
   $Loop = 0
   ContinueLoop
endif





$s = _INetGetSource ("http://" & $IPs[$x], True)
_FileWriteLog ($log, "Verifying Version for " & $IPs[$x])
$Version = ""


if $s = "" Then $version = "Notfound"

$Array = StringRegExp ($s,"(V......\d..)",3)
If IsArray ($Array) Then
    If StringRight ($Array[0],1) = "<" Then $Array[0] = StringTrimRight($Array[0],1)
    $version = $Array[0]
Else
    $version = "NotFound"
 EndIf

If $version = "V68.19.10z" Then
_FileWriteLog ($log, "Version is Up To Date")
FileWriteLine (@Scriptdir & "\updated.txt",$IPs[$x])
ContinueLoop
Else
 FileWriteLine (@Scriptdir & "\unabletoverify.txt",$IPs[$x])
_FileWriteLog ($log, "Version is "& $Version)
EndIf





;FileWriteLine ("H:\results.csv",$IPs[$x] & "," & $version)
Next

If FileExists (@Scriptdir & "\end.txt") Then
ExitLoop
endif
WEnd



Func close()
   Exit
   EndFunc

 

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.