How do i launch firefox from perl? i just need to launch the browser so WWW::Mechanize::Firefox can manipulate it. Searching around stackoverflow ive seen a few solutionsl like system('start cmd.exe /k $cmd)
where $cmd is arguments to throw as input once cmd is started.
However, these have not helped me to solve my problem at all.
solutions ive tried
system("start cmd.exe /k start firefox");
system("firefox");
system("cmd","start","firefox");
system("cmd start firefox");
Basically a lot of the alternatives ive found, but i could not launch Firefox browser at all.
You're on the right track. Your second line is almost correct. If firefox
is not in your PATH
environment variable, you need to supply the complete path.
Click on the Firefox icon on your desktop, open the properties and check where the firefox executable is located. Then use that with your system
call.
For me, it looks like this (the '
are for Perl's string, the "
are for the Windows shell, because the path has spaces in it):
system('"C:\Programme\Mozilla Firefox\firefox.exe"');
You can test it by opening a new command line (win + r, cmd
), cd
ing to the directory where your Perl program is run from, and just entering the command:
C:\Dokumente und Einstellungen\simbabque>"C:\Programme\Mozilla Firefox\firefox.exe"
It will not print anything, but just open a new Firefox window after a couple of seconds. So you'd probably need to hold your program execution in Perl while the browser is starting up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With