Recently I was heading the System testing and coorddinating UAT for a project. Occasinally I need to manually go unix and run some job. I hate to remember the sequence of those jobs, so I simply create a little tool for myself. It actually can be used for general purposes.
The command sequences are stored in XML files as showed below. The file is loaded in to a Tk::Listbox. Click on a task will show command sequence in a Tk::Text, and double click executes the sequence thru Net::Telnet.
use Net::Telnet; use Tk; use XML::Simple; use strict; use warnings; use constant HOST => "1"; use constant USERNAME => "2"; use constant PASSWORD => "3"; my $tasks = XMLin("command.xml"); my $mw = MainWindow->new(); my $list; $list = $mw->Scrolled("Listbox", yscrollcommand => sub {show_detail($l +ist->curselection())}, -scrollbars=>"e")->pack(-fill => 'x'); $list->bind("<1>", sub {show_detail($list->curselection())}); $list->bind("<Double-1>", sub {doit($list->curselection())}); my $detail = $mw->Scrolled("Text", -width => 40, -height=>10, -scrollb +ars=>"e")->pack(-fill => 'x'); for my $id (0..$#{@{$tasks->{"task"}}}) { $list->insert("end", $tasks->{"task"}->[$id]->{"description"}) +; } MainLoop; sub doit { my $task_id = shift; my $t = new Net::Telnet(timeout => 10, Prompt => '/\[AAUA1\]/' +); $t->open(HOST); $t->login(USERNAME, PASSWORD); my $cmds = $tasks->{"task"}->[$task_id]->{"command"}; for (0..$#{@{$cmds}}) { my @lines = $t->cmd($cmds->[$_]->{"string"}); print @lines; } } sub show_detail { my $task_id = shift; $detail->delete("\@1,1", "end"); my $cmds = $tasks->{"task"}->[$task_id]->{"command"}; for (0..$#{@{$cmds}}) { $detail->insert("end", $cmds->[$_]->{"string"} . "\n"); } }
<tasks> <task description="Publish PO"> <command string="cd ofg" /> <command string="POPublish.ksh 0" /> <command string="POExtractDriver.ksh TRICEPS 0" /> </task> <task description="Receiving PO"> <command string="cd ofg" /> <command string="POSubscribeDriver.ksh Triceps 0" /> <command string="POUpdateDriver.ksh" /> </task> <task description="Publish Orders"> <command string="cd ofg" /> <command string="POEvent.ksh" /> <command string="POPublish.ksh" /> </task> <task description="Publish Store Orders"> <command string="cd ofg/mcom" /> <command string="MCOMTricepsWriter.ksh" /> </task> <task description="Complete Store Orders"> <command string="cd ofg/mcom" /> <command string="TricepsMCOMWriter.ksh" /> </task> </tasks>
|
|---|