Hi everyone,
I'm trying to open an command file in windows, but fail. I had try save the command line in .txt and open it using perl but fail too.
Can somebody please help me, point me a direction?
Thanks,
Summer
how to open an command file (.cmd)
Started by summer5, Jun 21 2010 02:29 AM
5 replies to this topic
#1
Posted 21 June 2010 - 02:29 AM
|
|
|
#2
Posted 22 June 2010 - 10:01 PM
not sure what you mean perl is in .pl file and you need to download a interpreter to run it
#3
Posted 23 June 2010 - 01:06 AM
i want to write a perl script(.pl) to execute a command file(.cmd) after i replace the value in .cmd file.
To make perl script perform these function, i need an intepreter is it?
To make perl script perform these function, i need an intepreter is it?
#4
Posted 23 June 2010 - 07:30 PM
yes,i do install the perl interpretor: Activeperl. :>
#5
Posted 24 June 2010 - 02:35 AM
I'm not sure what you mean, but are you meaning you wish to open a process (on the .cmd file) after modifying it, and run it?
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#6
Posted 08 July 2010 - 01:16 AM
I think I got it. The OP wants to use a Perl script to modify a batch program (.cmd extension) and then run that batch program.
#!/usr/bin/env perl use strict; use warnings; use POSIX; my ($fd, $filetext, $endl); open($fd, "+<", $ARGV[0]) or die "Failed to open file for r/w: $!\n"; $endl = $/; undef $/; $filetext = <$fd>; $/ = $endl; $filetext =~ s/<thing to replace>/<stuff to replace with>/g; seek($fd, 0, SEEK_SET); print $fd $filetext; close($fd); system($ARGV[0]<other args here>); # more stuff if necessary here exit(1);Can't test it right now, but it should work. Note that this assumes that the first argument passed to the script is the name of the file you want to modify and run. Replace everything in < > as necessary, except <$fd>.
sudo rm -rf /


Sign In
Create Account

Back to top









