Well I don't have windows to test, but I'll try to get
you going. In the script, where you go into the launch sub
sub launch {
my $key = shift;
my $command = $commands{$key}{'com'};
if(fork==0){ exec "xterm -hold -e $command" }
}
you need to change the line
if(fork==0){ exec "xterm -hold -e $command" }
to something compatible with Windows.
The links I posted showed a few methods.
The easiest was using system with 1
system(1, $file_to_run );
So first, try changing the sub to
sub launch {
my $key = shift;
my $command = $commands{$key}{'com'};
system( 1, $command }
}
and don't forget to change the 'com' assignments in the
%commands hash to your programs
'1-1' => {text => 'Latex test',
com => "c:\texmf\miktex\bin\latex.exe test",
color=> 'pink'},
etc
etc
#######################################################
If the system( 1, $cmd) dosn't work, you may have to use
the code from the other node
use Win32:
rocess;
Win32:
rocess::Create($ProcessObj,
"C:\winnt\notepad.exe",
"c:\sample.txt",
0,
DETACHED_PROCESS,
".") || die "cant find the application";
#########################################################
Finally, you may have to experiment a bit yourself.
Setup a simple script, to see if it launches your app.
Keep trying until you succeed.
Like:
##############################################
#!/usr/bin/perl
use warnings;
use strict;
system( 1, "c:\texmf\miktex\bin\latex.exe test");
<>; #wait for keypress to simulate continued operation
__END__
#############################################
You may find that you need something like
"c:\texmf\miktex\bin\latex.exe", "test",
due to the syntax peculiarities of the windows command line.
Good luck.
Once again, thank you very much for all your help. I
followed your advise and modified the code (see below -
button.pl) and it works.
But I want a little more than this. Each button should
contain a sequence of commands - not just one - that are
executed one after the other once the button is pressed.
Moreover, these commands should have a options from
button.pl argument. For example,
perl button.pl exam
should make the button 1 to execute
c:\texmf\miktex\bin\latex.exe exam.tex
c:\texmf\miktex\bin\yap.exe exam.dvi
....
....
(in the code below, I had the second command in the
second button - but I want to have this as a second
command in button one - I may have to have more
commands) How can I do this? .. Raghu
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
my $mw = tkinit;
#$mw->geometry("400x400");
my $rF = $mw->Frame( -width => 400 )->grid;
my %buttons;
my %commands = (
'1-1' => {text => 'Latex ',
com => "c:\\texmf\\miktex\\bin\\latex.exe test",
color => 'pink'},
'1-2' => {text => 'yap',
com => "c:\\texmf\\miktex\\bin\\YAP.exe test",
color => 'lightblue'},
'1-3' => {text => 'Date', com =>'date', color=> 'pink'},
'1-4' => {text => 'top', com => 'ls -la', color
=> 'lightblue'},
'2-1' => {text => 'ps', com =>'date', color=> 'pink'},
'2-2' => {text => 'ls', com => 'ls -la', color
=> 'lightblue'},
'2-3' => {text => 'Dateyada', com =>'date',
color=> 'pink'},
'2-4' => {text => 'lsfoobar', com => 'ls -la', color =>
'lightblue'},
'3-1' => {text => 'Datexxxx', com =>'date',
color=> 'pink'},
'3-2' => {text => 'lsccc', com => 'ls -la', color =>
'lightblue'},
'3-3' => {text => 'Datebbbb', com =>'date',
color=> 'pink'},
'3-4' => {text => 'lsnnn', com => 'ls -la', color =>
'lightblue'},
'4-1' => {text => 'Date777', com =>'date',
color=> 'pink'},
'4-2' => {text => 'ls777', com => 'ls -la', color =>
'lightblue'},
'4-3' => {text => 'Dategggcom', com =>'date',
color=> 'pink'},
'4-4' => {text => 'lsgggcom', com => 'ls -la', color =>
'lightblue'},
);
foreach my $key(keys %commands){
my ($i, $j) = split /-/,$key;
$buttons{$key}{'button'} = $rF->Button(
-text => $commands{$key}{'text'},
-background => $commands{$key}{'color'},
-command => sub{ &launch( $key ) }
)->grid(-row=>$i, -column=> $j );
}
MainLoop;
sub launch {
my $key = shift;
my $command = $commands{$key}{'com'};
system( 1, $command );
}
__END__