How to silent install an exe file using perl script - perl

I want to silent install a software executable file using Perl coding.
I check to have a installer module to run executable file but no luck.
Kindly respond with some idea to initiate .

Would it not make sense to do something like that in a .bat or .ps1 file, using the command:
vlc-2.0.1-win32.exe /L=1033 /S
(just put the full filepath and executable file in there)?
That should result in a silent install, and looks easier for Windows than trying to use Perl? Or does it have to be Perl for whatever reason?

Related

TCL/TK Wish can't find file in the same directory

I am trying to write a TCL/TK Script that accesses an INI File with the command [::ini::open DBW.ini]. I am using the inifile package for this and am trying to run on wish for the gui.
However, wish answers with "couldn't open "DBW.ini": no such file or directory". The odd thing about this is, that I can run this Code in the VSCode extension "Code Runner".
Code Runner is configured to access the same wish Compiler that I'm trying to run on my Windows System.
Why would I be able to run this Code through VSCode, but when im using the wish Compiler directly it throws an error message.
Thank you in advance
Most likely your Tcl code is not being executed in the same directory as where the DBW.ini file is. The Tcl command pwd will return the directory where the code is executing. If this is not where the ini file is, a simple fix would be to specify the whole path to the file when you try to open it, something like:
[::ini::open C:/some/where/DBW.ini]

Can we run a Perl script in a browser without web server?

Is it possible to run a perl script in Activeperl without web server in windows 7.If possible what are the steps to follow?
I have simple registration form using Post method in HTML file.I'm using this HTML file in my .pl file.I'm using CGI module. While running the .pl file from the command promt the HTML file is running browser, after clicking submit button the perl script is displaying.
When you install ActivePerl, it creates a file association for .pl files, so simply double-clicking a .pl file in Explorer ("My Computer", "File Explorer", etc) will run it. This also makes it so you can run script.pl from the Windows Command Prompt.
When you install ActivePerl, it modifies your PATH to include the directory that contains perl.exe, making it so you can run perl script.pl from the Windows Command Prompt.
Finally, you can always run c:\...\bin\perl script.pl from the Windows Command Prompt.
Can you explain a bit more the exact use-case?
I think the first user in the comments gave you the best answer.
If Perl is not in your PATH environment you need to associate .pl extensions with Perl or run it via command-line ( if I remember correctly Active-Perl comes with a Perl command line tool )

Adding perl script to module distribution and making it accessible globally

I'm wondering if there is a tutorial or simple way to add perl scripts which I've written to be accessible to the user globally.
for eg. you apps like Carton, Cpanm, much like how npm has an npm install -g option.
I tried placing my scripts in the bin directory of my perl package but its not working.
The App::* area of cpan contains installable tools and utilities. Looking at a small one, like App::p I saw that its structure looked like it contained a Makefile.PL that used ExtUtils::MakeMaker to define how to build test and install the relatively small perl script.
However, if you're talking about just taking a script you wrote and making it something executable by you, the user, then it's basically the same way all scripting works (apologies if you weren't asking this):
One Unix, Linux and Mac OS X when using a shell like bash:
Any file can be made executable to the user by running chmod u+x filename
An executable file should start with a magic number, for plain text files containing scripts, the shebang is that number. So start your files with (as covered in man perlintro):
#!/usr/bin/perl
use strict;
use warnings;
When specifying an executable file from the command line you can type in the full path, possibly with conveniences from your shell. EG the file is at $HOME/myscripts/runme.pl you can type that at the prompt, the expanded /home/username/myscripts/runme.pl (/Users/username/myscripts/runme.pl on Mac OS X) or ~/myscripts/runme.pl at a bash prompt. Or if runme.pl is in your current working directory: ./runme.pl
If you just type runme.pl sh and bash and many shells will search your PATH variable in order and run the first runme.pl in any of the specified paths.
So if echo $PATH gives you something like: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin and you want the example in point 3 to work with just runme.pl you should
Either move the file into one of those directories (not recommended).
Or add export PATH=$PATH:$HOME/myscripts to the bottom of your ~/.bashrc or ~/.profile file or likewise for your preferred shell. Be sure to open a new login shell session, EG close that terminal window and open a new one.
On Windows, this is an exercise left to the reader. ☺

How can I automate a Perl installation / script

I'm brand new to Perl. We have a useful script in the office that people would like to use. Unfortunately it has been deemed hard to setup because one has to download and install Strawberry Perl, manually install a few CPAN modules from the command line, and then run the script with the right arguments. It's really not that bad and there is a readme to follow but is there an easier way to handle the installation? I'm sure I could make a batch file to install the CPAN modules, but what about setting up the environment variables (if needed)? I don't suppose there is a way to automate the Strawberry Perl installation or have it 'come with' the necessary modules?
How would you normally install software on client workstations? That's the method you should use now.
If you don't have anything like that, I would suggest using psexec http://technet.microsoft.com/en-gb/sysinternals/bb897553.aspx
You should be able to 'silent install' Strawberry Perl with the MSI installer.
http://msdn.microsoft.com/en-us/library/aa372024%28v=vs.85%29.aspx
Then use psexec again, to do the CPAN installs.
If you need to do environment variables, then you can either do that within your perl script, or you might have to mess with the Windows registry remotely.
Create a BAT or CMD script that runs the Perl installer, followed by the CPAN install commands. The trick is probably that when the BAT starts, the Perl install area (C:\Perl\bin or whatever) won't be on the search PATH. That will make it hard to run the CPAN commands. So, the BAT script should include a command to manually add the path to CPAN into the script's environment. You can even build up a list of modules, and run them in a loop. I use ActiveState, not Strawberry Perl, but my installer looks like:
#echo off
Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0
REG.exe Query %RegQry% > "%TEMP%\checkOS.txt"
Find /i "x86" < "%TEMP%\CheckOS.txt"
If %ERRORLEVEL% == 0 (
echo This is 32-bit operating system...
\\Server\Shares\Installers\ActivePerl-5.16.3.1603-MSWin32-x86-296746.msi
) ELSE (
echo This is 64-bit operating system...
\\Server\Shares\Installers\ActivePerl-5.16.3.1603-MSWin32-x64-296746.msi
)
REM Even though the above stuff should have installed Perl locally and updated the PATH,
REM the new PATH won't be available in this BAT script since it was launched before the change.
REM Add both possible locations for local Perl to the PATH before running the PPM commands below.
PATH=C:\Perl64\bin;C:\Perl\bin;%PATH%
set MODULE_LIST=(Archive-Extract DBI DBD-ODBC Data-Validate Date-Manip Date-Simple File-Copy-Recursive List-MoreUtils Mail-Sender Mail-Sendmail Params-Validate SOAP-Lite Spreadsheet-WriteExcel Text-CSV Tie-IxHash)
for %%i in %MODULE_LIST% do cmd/c ppm install %%i
Your final line would be a cpan command install of ppm, but hopefully you get the idea!

How to get Powershell to run SH scripts

Can someone please tell me how I get Powershell to run .sh scripts? It keeps just trying to open the file i need in Notepad when I run this command:
.\update-version.sh 123
I've added .SH to my PATHEXT environment variable and also added the Microsoft.PowerShell_profile.ps1 directory to the Path environment variable.
PowerShell scripts have a .ps1 extension (along with other supported extensions such as psm1,psd1 etc) it will not run other extensions other than that.
I had also got the same issue when i am trying to run .sh files. The solution is you need to enable bash shell by typing bash.After enabling Bash on Windows, you can run .sh files by typing bash ./fileName.sh. But i have tried through git bash with typing . fileName.sh it worked well. These are the two solutions that I have found, and you can try whatever you wish.