CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Automating cmd prompt command execution

 

First page Previous page 1 2 Next page Last page  View All


mohan
User

Sep 4, 2015, 1:43 AM

Post #1 of 27 (7700 views)
Automating cmd prompt command execution Can't Post

Hi Ppl,

I'm new to Perl. I have written a code in C# for the below funtion:

1. open cmd
2. Set the directory in which the program is running as the currect path
3. Detect a file with extension ".mobi" and run the below command in cmd :

"kindletool.exe strip_source filename.mobi "

4. If there is a file with ".epub" extension then rename the extension to ".zip".

Here is the code that I used in c# :



Code
class MainClass 
{
static void Main()
{

Directory.SetCurrentDirectory(@"C:\Users\madhanl\Desktop\Convert");
string strCmdText;
strCmdText = "/C kindletool.exe strip_source 123.mobi";
System.Diagnostics.Process.Start("CMD.exe", strCmdText);
//--------------------------------------------------------


string directoryPath = @"C:\Users\madhanl\Desktop\Convert";
string[] search = Directory.GetFiles(directoryPath, "*.epub", SearchOption.AllDirectories);

if (search.Length == 1)
{
string filePath = search[0].Substring(0, search[0].Length - 4);
string newPath = filePath + "zip";
File.Copy(search[0], newPath, true);
File.Delete(search[0]);
Console.WriteLine("Renamed {0} to {1} PRESS ANY KEY TO EXIT", search[0], newPath);
}
else if (search.Length == 0)
{
Console.WriteLine("Couldn't find any .epub files.... PRESS ANY KEY TO EXIT");
}
else
{
Console.WriteLine("More than one .epub file exists");
}

Console.ReadKey();
}
}

//


I want this code in Perl. Then convert it into exe file so that it can be executed on any system. Can someone please help me in doing this?


(This post was edited by mohan on Sep 4, 2015, 2:05 AM)


Laurent_R
Veteran / Moderator

Sep 4, 2015, 4:33 AM

Post #2 of 27 (7694 views)
Re: [mohan] Automating cmd prompt command execution [In reply to] Can't Post

Sure, we are willing to help you. But this site is not a free code-writing service, but a site for getting some help and for learning. Please show the Perl code you've written, and tell us in which respect it does not do what you expect, and we'll gladly help you.

Just a couple of Perl functions that might be useful:
- changing directory: chdir $newdir;
- deleting files: unlink $file;
- writing lines to the screen: print "message\n";
- executing an external program: system("command"); or my $output = `command`;

Hope this helps.

Additional note: while you can produce exe files, this is not (by far) the most common way to use Perl programs.


mohan
User

Sep 8, 2015, 1:49 AM

Post #3 of 27 (7554 views)
Re: [Laurent_R] Automating cmd prompt command execution [In reply to] Can't Post

Sure Laurent ! Will try write few lines of code and seek help..


mohan
User

Sep 8, 2015, 2:15 AM

Post #4 of 27 (7553 views)
Re: [Laurent_R] Automating cmd prompt command execution [In reply to] Can't Post

system 'start cmd.exe @cmd /k "cd C:\Users\user\Desktop\Convert" ';

I managed to write the above code that will open cmd.exe and set the desired path. I now want the code to search for .mobi or .prc or .epub file in "Convert" folder and do a particular action based on the file type found. Can you please guide me here..


mohan
User

Sep 8, 2015, 3:23 AM

Post #5 of 27 (7549 views)
Re: [mohan] Automating cmd prompt command execution [In reply to] Can't Post

I figured it out :


Code
#!/usr/bin/perl 
use warnings;
use strict;


for my $file (glob '*.mobi *.prc *.epub') {
my ($ext) = $file =~ /\.(.*)/;
if ($ext =~ /mobi|prc/i) {
my $status = system qw{ kindletool.exe strip_source }, $file;
warn "Failure $status: $file" if $status;

} elsif (lc $ext eq 'epub') {
(my $newname = $file) =~ s/\.epub$/.zip/;
rename $file, $newname or warn "Failure $!: $file";
}
}


Is there any way to convert this into exe file so that it can be executed on machines that doesn't have perl ?


FishMonger
Veteran / Moderator

Sep 8, 2015, 6:10 AM

Post #6 of 27 (7541 views)
Re: [mohan] Automating cmd prompt command execution [In reply to] Can't Post


Quote
I figured it out

lol

You mean someone wrote the code for you.
http://perlmonks.org/?node_id=1141331


Quote
Is there any way to convert this into exe file so that it can be executed on machines that doesn't have perl ?

Yes, there are several options.

http://search.cpan.org/~rschupp/PAR-Packer-1.026/lib/PAR/Packer.pm
http://www.indigostar.com/perl2exe.php


mohan
User

Sep 8, 2015, 6:55 AM

Post #7 of 27 (7537 views)
Re: [FishMonger] Automating cmd prompt command execution [In reply to] Can't Post

Yes, That's what i meant :) I was in a bit of time constrain and really needed help to sort this out :) :) Thanks for the help ! :)


mohan
User

Sep 9, 2015, 3:58 AM

Post #8 of 27 (7519 views)
Re: [FishMonger] Automating cmd prompt command execution [In reply to] Can't Post

When I used perl2exe, i get this error message while running the exe file :

can't locate File/Glob.pm in@INC

Any idea on how to fix this?


FishMonger
Veteran / Moderator

Sep 9, 2015, 6:21 AM

Post #9 of 27 (7516 views)
Re: [mohan] Automating cmd prompt command execution [In reply to] Can't Post

The script you posted is not using that module. Did you modify the script?

Try using the -I option to add the module's directory location when creating the exe.
http://www.indigostar.com/pxman.html

Or, you can try using the pp command from Par::Packer to create the exe?
http://search.cpan.org/~rschupp/PAR-Packer-1.026/lib/pp.pm


Laurent_R
Veteran / Moderator

Sep 9, 2015, 2:25 PM

Post #10 of 27 (7511 views)
Re: [FishMonger] Automating cmd prompt command execution [In reply to] Can't Post


In Reply To
The script you posted is not using that module. Did you modify the script?


Hmm, not sure, but maybe it does use it behind the scene. I have read several times something to the effect that the glob internal builtin is actually using the Glob module for its implementation, but I frankly do not know the details.


FishMonger
Veteran / Moderator

Sep 9, 2015, 2:37 PM

Post #11 of 27 (7508 views)
Re: [Laurent_R] Automating cmd prompt command execution [In reply to] Can't Post

Hmm, it looks like you're correct.


Code
[root@099-91-RKB-2 ~]# cat test.pl 
#!/usr/bin/perl

use strict;
use warnings;

my @files = glob '*.pl';

[root@099-91-RKB-2 ~]# perl -MO=Deparse test.pl
use File::Glob ();
use warnings;
use strict 'refs';
my(@files) = glob('*.pl');
test.pl syntax OK



mohan
User

Sep 9, 2015, 9:16 PM

Post #12 of 27 (7501 views)
Re: [FishMonger] Automating cmd prompt command execution [In reply to] Can't Post

THis is the script that i used:


Code
#!/usr/bin/perl 
use warnings;
use strict;


for my $file (glob '*.mobi *.prc *.epub') {
my ($ext) = $file =~ /\.(.*)/;
if ($ext =~ /mobi|prc/i) {
my $status = system qw{ kindletool.exe strip_source }, $file;
warn "Failure $status: $file" if $status;

} elsif (lc $ext eq 'epub') {
(my $newname = $file) =~ s/\.epub$/.zip/;
rename $file, $newname or warn "Failure $!: $file";
}
}



mohan
User

Sep 9, 2015, 9:37 PM

Post #13 of 27 (7499 views)
Re: [FishMonger] Automating cmd prompt command execution [In reply to] Can't Post

how do i run the PAR Packer? Please guide me..I'm lost here


FishMonger
Veteran / Moderator

Sep 10, 2015, 6:58 AM

Post #14 of 27 (7471 views)
Re: [mohan] Automating cmd prompt command execution [In reply to] Can't Post

Before we switch to using PAR::Packer, lets try perl2exe since you've already worked with it and both approaches will require the same type of adjustment.

Since the glob function is using File::Glob under the hood (without needing an explicit use statement to load it), it would appear that perl2exe is not seeing that dependency. So, lets add the explicit use statement so that perl2exe will know about it then compile the script.


Code
#!/usr/bin/perl 

use warnings;
use strict;
use File::Glob;


for my $file (glob '*.mobi *.prc *.epub') {
my ($ext) = $file =~ /\.(.*)/;
if ($ext =~ /mobi|prc/i) {
my $status = system qw{ kindletool.exe strip_source }, $file;
warn "Failure $status: $file" if $status;

} elsif (lc $ext eq 'epub') {
(my $newname = $file) =~ s/\.epub$/.zip/;
rename $file, $newname or warn "Failure $!: $file";
}
}



mohan
User

Sep 10, 2015, 10:31 PM

Post #15 of 27 (7458 views)
Re: [FishMonger] Automating cmd prompt command execution [In reply to] Can't Post

I tried as you said using perl2exe. But I get the error message when I run the exe. Refer the screenshot.
Attachments: error.JPG (70.2 KB)


FishMonger
Veteran / Moderator

Sep 11, 2015, 6:34 AM

Post #16 of 27 (7442 views)
Re: [mohan] Automating cmd prompt command execution [In reply to] Can't Post

It looks like perl2exe is a little behind in its perl version support. The perl2exe version you have (which appears to be the newest) supports upto perl v5.16.3 but it looks like you have perl v5.20.2.

It looks like you need to switch over to using the pp command from Par::Packer.

Once Par::Packer is installed, you would use the pp command to compile/package the script into an exe.

Instructions/examples on how to use the pp command is found here: http://search.cpan.org/~rschupp/PAR-Packer-1.026/lib/pp.pm


mohan
User

Sep 11, 2015, 6:55 AM

Post #17 of 27 (7439 views)
Re: [FishMonger] Automating cmd prompt command execution [In reply to] Can't Post

I downloaded the par packer file in the link. How do i now install this? Should i copy paste this folder inside the "bin" folder of perl or something ? Or can I initiate it in cmd


FishMonger
Veteran / Moderator

Sep 11, 2015, 7:00 AM

Post #18 of 27 (7436 views)
Re: [mohan] Automating cmd prompt command execution [In reply to] Can't Post

There's no need to manually download the tar file. Use the cpan tool to install modules; it will handle the downloading, unpacking, building, and installing.

c:\>cpan install PAR::Packer


(This post was edited by FishMonger on Sep 11, 2015, 7:03 AM)


mohan
User

Sep 14, 2015, 3:32 AM

Post #19 of 27 (7384 views)
Re: [FishMonger] Automating cmd prompt command execution [In reply to] Can't Post

I did the above steps and got this huge message:

Code
C:\Users\mohad>cpan install PAR::Packer 
CPAN: Term::ANSIColor loaded ok (v4.03)
CPAN: Storable loaded ok (v2.49_01)
Reading 'C:\Perl64\cpan\Metadata'
Database was generated on Thu, 10 Sep 2015 05:17:02 GMT
CPAN: LWP::UserAgent loaded ok (v6.13)
CPAN: Time::HiRes loaded ok (v1.9726)
Fetching with LWP:
http://ppm.activestate.com/CPAN/authors/01mailrc.txt.gz
CPAN: YAML::XS loaded ok (v0.52)
Reading 'C:\Perl64\cpan\sources\authors\01mailrc.txt.gz'
CPAN: Compress::Zlib loaded ok (v2.068)
............................................................................DONE

Fetching with LWP:
http://ppm.activestate.com/CPAN/modules/02packages.details.txt.gz
Reading 'C:\Perl64\cpan\sources\modules\02packages.details.txt.gz'
Database was generated on Sun, 13 Sep 2015 05:41:02 GMT
..............
New CPAN.pm version (v2.10) available.
[Currently running version is v2.05]
You might want to try
install CPAN
reload cpan
to both upgrade CPAN.pm and run the new version without leaving
the current session.


..............................................................DONE
Fetching with LWP:
http://ppm.activestate.com/CPAN/modules/03modlist.data.gz
Reading 'C:\Perl64\cpan\sources\modules\03modlist.data.gz'
DONE
Writing C:\Perl64\cpan\Metadata
Running install for module 'PAR::Packer'
CPAN: Digest::SHA loaded ok (v5.95)
Checksum for C:\Perl64\cpan\sources\authors\id\R\RS\RSCHUPP\PAR-Packer-1.026.tar
.gz ok
CPAN: Archive::Tar loaded ok (v2.04)
PAR-Packer-1.026/
PAR-Packer-1.026/myldr/
PAR-Packer-1.026/myldr/run_with_inc.pl
PAR-Packer-1.026/myldr/encode_append.pl
PAR-Packer-1.026/myldr/Dynamic.in
PAR-Packer-1.026/myldr/sha1.c.PL
PAR-Packer-1.026/myldr/boot.c
PAR-Packer-1.026/myldr/winres/
PAR-Packer-1.026/myldr/winres/pp.ico
PAR-Packer-1.026/myldr/winres/pp.rc
PAR-Packer-1.026/myldr/winres/pp.manifest
PAR-Packer-1.026/myldr/Makefile.PL
PAR-Packer-1.026/myldr/env.c
PAR-Packer-1.026/myldr/internals.c
PAR-Packer-1.026/myldr/main.c
PAR-Packer-1.026/myldr/file2c.pl
PAR-Packer-1.026/myldr/usernamefrompwuid.c
PAR-Packer-1.026/myldr/par_pl2c.pl
PAR-Packer-1.026/myldr/mktmpdir.h
PAR-Packer-1.026/myldr/utils.c
PAR-Packer-1.026/myldr/mktmpdir.c
PAR-Packer-1.026/myldr/Static.in
PAR-Packer-1.026/MANIFEST.SKIP
PAR-Packer-1.026/contrib/
PAR-Packer-1.026/contrib/stdio/
PAR-Packer-1.026/contrib/stdio/Stdio_readme.txt
PAR-Packer-1.026/contrib/stdio/Stdio.pm
PAR-Packer-1.026/contrib/gui_pp/
PAR-Packer-1.026/contrib/gui_pp/gpp_readme.txt
PAR-Packer-1.026/contrib/gui_pp/gpp
PAR-Packer-1.026/contrib/pare/
PAR-Packer-1.026/contrib/pare/pare_readme.txt
PAR-Packer-1.026/contrib/pare/pare
PAR-Packer-1.026/contrib/procedural_pp/
PAR-Packer-1.026/contrib/procedural_pp/pp_old
PAR-Packer-1.026/contrib/automated_pp_test/
PAR-Packer-1.026/contrib/automated_pp_test/automated_pp_test.pl
PAR-Packer-1.026/contrib/automated_pp_test/hello_tk.pl
PAR-Packer-1.026/contrib/automated_pp_test/hi.ico
PAR-Packer-1.026/contrib/automated_pp_test/pipe_a_command.pm
PAR-Packer-1.026/contrib/automated_pp_test/prior_to_test.pm
PAR-Packer-1.026/contrib/automated_pp_test/remove_file_and_try_executable_again.
pm
PAR-Packer-1.026/contrib/automated_pp_test/test_in_further_subdir.pm
PAR-Packer-1.026/contrib/extract_embedded/
PAR-Packer-1.026/contrib/extract_embedded/extract-embedded.pl
PAR-Packer-1.026/contrib/docs/
PAR-Packer-1.026/contrib/docs/where_is_it.txt
PAR-Packer-1.026/contrib/docs/who_am_i.txt
PAR-Packer-1.026/inc/
PAR-Packer-1.026/inc/Module/
PAR-Packer-1.026/inc/Module/Install.pm
PAR-Packer-1.026/inc/Module/Install/
PAR-Packer-1.026/inc/Module/Install/Win32.pm
PAR-Packer-1.026/inc/Module/Install/Makefile.pm
PAR-Packer-1.026/inc/Module/Install/WriteAll.pm
PAR-Packer-1.026/inc/Module/Install/PAR.pm
PAR-Packer-1.026/inc/Module/Install/Fetch.pm
PAR-Packer-1.026/inc/Module/Install/Include.pm
PAR-Packer-1.026/inc/Module/Install/Metadata.pm
PAR-Packer-1.026/inc/Module/Install/Can.pm
PAR-Packer-1.026/inc/Module/Install/Base.pm
PAR-Packer-1.026/script/
PAR-Packer-1.026/script/pp
PAR-Packer-1.026/script/par.pl
PAR-Packer-1.026/script/tkpp
PAR-Packer-1.026/script/parl.pod
PAR-Packer-1.026/t/
PAR-Packer-1.026/t/20-pp.t
PAR-Packer-1.026/t/30-current_exec.t
PAR-Packer-1.026/t/00-pod.t
PAR-Packer-1.026/t/test-proc
PAR-Packer-1.026/t/40-packer_cd_option.t
PAR-Packer-1.026/t/90-rt59710.t
PAR-Packer-1.026/t/10-parl-generation.t
PAR-Packer-1.026/Makefile.PL
PAR-Packer-1.026/package/
PAR-Packer-1.026/package/parl.nsi
PAR-Packer-1.026/lib/
PAR-Packer-1.026/lib/PAR/
PAR-Packer-1.026/lib/PAR/Packer.pm
PAR-Packer-1.026/lib/PAR/StrippedPARL/
PAR-Packer-1.026/lib/PAR/StrippedPARL/Base.pm
PAR-Packer-1.026/lib/PAR/Filter/
PAR-Packer-1.026/lib/PAR/Filter/PodStrip.pm
PAR-Packer-1.026/lib/PAR/Filter/Bleach.pm
PAR-Packer-1.026/lib/PAR/Filter/PatchContent.pm
PAR-Packer-1.026/lib/PAR/Filter/Bytecode.pm
PAR-Packer-1.026/lib/PAR/Filter/Obfuscate.pm
PAR-Packer-1.026/lib/PAR/Filter.pm
PAR-Packer-1.026/lib/pp.pm
PAR-Packer-1.026/lib/App/
PAR-Packer-1.026/lib/App/Packer/
PAR-Packer-1.026/lib/App/Packer/PAR.pm
PAR-Packer-1.026/TODO
PAR-Packer-1.026/Changes
PAR-Packer-1.026/MANIFEST
PAR-Packer-1.026/README
PAR-Packer-1.026/AUTHORS
PAR-Packer-1.026/META.yml
CPAN: File::Temp loaded ok (v0.2304)
CPAN: Parse::CPAN::Meta loaded ok (v1.4414)
CPAN: CPAN::Meta loaded ok (v2.140640)
CPAN: Module::CoreList loaded ok (v5.20150520)
Configuring R/RS/RSCHUPP/PAR-Packer-1.026.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Prototype mismatch: sub main::prompt: none vs ($;$) at C:/Perl64/lib/ExtUtils/Ma
keMaker.pm line 221.
Warning (mostly harmless): No library found for -lmoldname
Warning (mostly harmless): No library found for -lkernel32
Warning (mostly harmless): No library found for -luser32
Warning (mostly harmless): No library found for -lgdi32
Warning (mostly harmless): No library found for -lwinspool
Warning (mostly harmless): No library found for -lcomdlg32
Warning (mostly harmless): No library found for -ladvapi32
Warning (mostly harmless): No library found for -lshell32
Warning (mostly harmless): No library found for -lole32
Warning (mostly harmless): No library found for -loleaut32
Warning (mostly harmless): No library found for -lnetapi32
Warning (mostly harmless): No library found for -luuid
Warning (mostly harmless): No library found for -lws2_32
Warning (mostly harmless): No library found for -lmpr
Warning (mostly harmless): No library found for -lwinmm
Warning (mostly harmless): No library found for -lversion
Warning (mostly harmless): No library found for -lodbc32
Warning (mostly harmless): No library found for -lodbccp32
Warning (mostly harmless): No library found for -lcomctl32
Generating a dmake-style Makefile
Writing Makefile for myldr
Writing MYMETA.yml and MYMETA.json
Generating a dmake-style Makefile
Writing Makefile for PAR::Packer
Writing MYMETA.yml and MYMETA.json
RSCHUPP/PAR-Packer-1.026.tar.gz
C:\Perl64\bin\perl.exe Makefile.PL INSTALLDIRS=site -- OK
Running make for R/RS/RSCHUPP/PAR-Packer-1.026.tar.gz
cp lib/PAR/Filter/Bleach.pm blib\lib\PAR\Filter\Bleach.pm
cp lib/pp.pm blib\lib\pp.pm
cp lib/PAR/StrippedPARL/Base.pm blib\lib\PAR\StrippedPARL\Base.pm
cp lib/PAR/Filter/PatchContent.pm blib\lib\PAR\Filter\PatchContent.pm
cp lib/PAR/Packer.pm blib\lib\PAR\Packer.pm
cp lib/PAR/Filter.pm blib\lib\PAR\Filter.pm
cp lib/PAR/Filter/Bytecode.pm blib\lib\PAR\Filter\Bytecode.pm
cp lib/App/Packer/PAR.pm blib\lib\App\Packer\PAR.pm
cp lib/PAR/Filter/Obfuscate.pm blib\lib\PAR\Filter\Obfuscate.pm
cp lib/PAR/Filter/PodStrip.pm blib\lib\PAR\Filter\PodStrip.pm
C:\Perl64\bin\perl.exe par_pl2c.pl my_par_pl < ..\script\par.pl > my_par_pl.c
C:\Perl64\bin\perl.exe sha1.c.PL
C:\Perl64\site\bin\gcc.exe -c -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTM
ODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUS
E_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields -I"C:\Perl64\lib\CORE" -D
PARL_EXE=\"parl.exe\" -s -O2 main.c
main.c: In function 'main':
main.c:121:23: warning: assignment discards 'const' qualifier from pointer targe
t type [enabled by default]
windres -i winres/pp.rc -o ppresource.coff --input-format=rc --output-format=cof
f --target=pe-x86-64
'windres' is not recognized as an internal or external command,
operable program or batch file.
dmake.exe: Error code 129, while making 'ppresource.coff'
dmake.exe: Error code 255, while making 'subdirs'
RSCHUPP/PAR-Packer-1.026.tar.gz
C:\Perl64\site\bin\dmake.exe -- NOT OK


Does this mean that it's installed? what is the next step?


mohan
User

Sep 17, 2015, 7:25 AM

Post #20 of 27 (7316 views)
Re: [FishMonger] Automating cmd prompt command execution [In reply to] Can't Post

Any help here? Is everything installed correctly?


Laurent_R
Veteran / Moderator

Sep 17, 2015, 8:14 AM

Post #21 of 27 (7311 views)
Re: [mohan] Automating cmd prompt command execution [In reply to] Can't Post


In Reply To
Is everything installed correctly?


Probably not, but I am sorry that I have to say that I have no idea how to remotely help you.


FishMonger
Veteran / Moderator

Sep 17, 2015, 8:36 AM

Post #22 of 27 (7311 views)
Re: [mohan] Automating cmd prompt command execution [In reply to] Can't Post

No, the module did not install.


Quote
'windres' is not recognized as an internal or external command, operable program or batch file.

Do you have windres.exe on your system and is it within your path environment?

You have 2 things working against you (1) Activestate perl and (2) Activestate 64 bit perl, which boils down to 1 problem, that being Activestate.

Activestate perl is broken in a number of ways, primarily with its module support and installation. Activestate doesn't come with the proper tools (i.e. compiler) to build modules, which is part of the reason they have the PPM utility to download/install precompiled modules instead of using CPAN. Some people download nmake.exe or dmake.exe (it appears that's what you have done) which works ok on Windows 32bit systems, but not quite as well with 64bit systems. The next step up would be to install MinGW which provides the compiler and other helper tools. There is both a 32bit and 64bit version.

The best solution to this problem is to drop Activestate and switch over to using Strawberry perl, which is what I and many many others have done. Strawberry perl comes with the required compiler tools to build modules. That doesn't mean that you'll never have build problems like this, but it does mean that they will be few and far between.

I'm currently on a Win7 32bit system using Strawberry perl and PAR::Packer installed without any problems. Later today when I get home I can verify the installation on my Win7 64bit system.


(This post was edited by FishMonger on Sep 17, 2015, 8:43 AM)


bulrush
User

Sep 19, 2015, 5:56 AM

Post #23 of 27 (7293 views)
Re: [mohan] Automating cmd prompt command execution [In reply to] Can't Post

Mohan,

You might be better off using a bash script because bash is available on all modern linux systems, and it's a powerful scripting language. Then use Perl to call the bash shell script.

In Perl:


Code
$cmd='/path/to/bashscript file.epub'; 
@output=`$cmd`; # Sends output to an array, one line per array position


The bash script would look something like this:


Code
#!/bin/bash 
# $1 is the first parameter, $2 the second, $3 the third, etc.
kindletool strip_source $1

-----


FishMonger
Veteran / Moderator

Sep 19, 2015, 6:20 AM

Post #24 of 27 (7291 views)
Re: [bulrush] Automating cmd prompt command execution [In reply to] Can't Post


Quote
You might be better off using a bash script because bash is available on all modern linux systems


You response doesn't make much sense since mohan is running this on Windows, not Linux.

Even if mohan was on Linux, your suggestion only adds an additional and unnecessary step which is also anther place where something can go wrong.

Are you forgetting about the art of KISS?

Another thing to realize is that mohan's problem is no longer about "Automating cmd prompt command execution". It's about bundling the now working script into a standalone Windows .exe executable. That issue should have been broken off into a new question/thread.


mohan
User

Oct 18, 2015, 10:58 PM

Post #25 of 27 (7090 views)
Re: [FishMonger] Automating cmd prompt command execution [In reply to] Can't Post

Hi Guys,

Sorry, I was hospitalized due to viral fever and was not able to follow up on this thread.

I tried this out in a new system and the exe file was created ! :)

Thank you all soo much for the constant help !

First page Previous page 1 2 Next page Last page  View All
 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives