automating script that uses command line?

Sorry for what I'm positive is a dopey question, but I'm a rank 
beginner at Perl in general and MacPerl in particular. I *have* spent 
literally hours going through the archives of this list and the 
MacPerl documentation trying to help myself, and I see fragments of 
answers but nothing that has yet worked for me...

I am using a wonderful Perl script called MHonArc 2.5 -- in fact this 
is the same script that is used to create the MacPerl archives on the 
web.

(For info: http://www.nacs.uci.edu/indiv/ehood/MHonArc/doc/mhonarc.html )

My procedure for using MHonarc on my Mac is this:

  * Start MacPerl (5.2.0r4)

  * I do Command-R to run a script, then I select the  MHonArc script

  * I get a prompt for a command line, then I type:
     mailboxname  -outdir  :outputpath  -rcfile  resourcefile.rsc  -add

This works great, and MHonArc speedily creates a set of web pages for 
me based on my Eudora mailbox.

My problem is that I can't figure out how to automate it, and I'll 
need to do it once a day.  On a unix system one would just type 
something on the shell like:

       #  mhonarc  mailboxname  -outdir  :outputpath  -rcfile 
resourcefile.rsc  -add

And so it would be really easy to make a shellscript to do this.

I've tried writing an AppleScript, and I can launch MacPerl and 
MHonArc from AppleScript just fine, but I can't figure out how to 
simulate typing in the command line. (There are a ton of posts on 
this topic in the MacPerl list archives, with many different 
solutions to this issue, but none of the solutions seem to work for 
me.)

In any event, it seems a little silly to use AppleScript for this - 
but I don't even know how to get started to write a simple MacPerl 
script that will start up another existing script and feed it the 
correct command line options.

Any advice? Thanks. -Steve
0
steve_rothman
1/29/2001 4:27:19 PM
perl.macperl 876 articles. 0 followers. Follow

7 Replies
676 Views

Similar Articles

[PageSpeed] 44
Get it on Google Play
Get it on Apple App Store

>Sorry for what I'm positive is a dopey question.

It's been around for the whole life of MacPerl. There are workarounds and I'm sure someone will point them out.

Personally I use the MPW tool version of MaPerl. It allows a full command line just as you are used to. There is also a feature of MPW which is the ToolServer. You can make up an MPW script as a text file which works just like a script on a UNIX platform. The finder will respond to doubleclicking the text file by starting ToolServer which will pass the command line to the perl tool.

MacOS exx will probably completely eliminate the problem.


-- 

-> From the U S of A, the only socialist country that refuses to admit it. <-
0
dmcnutt
1/29/2001 6:10:40 PM
At 11:27 -0500 01.29.2001, Steve Rothman wrote:
>And so it would be really easy to make a shellscript to do this.
>
>I've tried writing an AppleScript, and I can launch MacPerl and
>MHonArc from AppleScript just fine, but I can't figure out how to
>simulate typing in the command line. (There are a ton of posts on
>this topic in the MacPerl list archives, with many different
>solutions to this issue, but none of the solutions seem to work for
>me.)

	tell app "MacPerl"
		do script ["mhonarc", "mailboxname", "-outdir", �
			":outputpath", "-rcfile", "resourcefile.rsc", "-add"]
	end


You will probably need the whole path to "mhonarc" in there.

As to starting existing scripts ... you could possibly do:

	#!perl
	@ARGV = ("mailboxname", "-outdir", ":outputpath",
		"-rcfile", "resourcefile.rsc", "-add");
	do 'mhonarc';

Or you could, if you have MPW perl set up, do:

	#!perl
	my $cmd = 'mhonarc  mailboxname  -outdir  :outputpath  -rcfile ' .
		'resourcefile.rsc  -add';
	`$cmd`;

It should work just fine if "mhonarc" is in your MPW scripts folder.

-- 
Chris Nandor                      pudge@pobox.com    http://pudge.net/
Open Source Development Network    pudge@osdn.com     http://osdn.com/
0
pudge
1/29/2001 6:39:30 PM
>  >I've tried writing an AppleScript, and I can launch MacPerl and
>>MHonArc from AppleScript just fine, but I can't figure out how to
>  >simulate typing in the command line.

>
>	tell app "MacPerl"
>		do script ["mhonarc", "mailboxname", "-outdir", =AC
>			":outputpath", "-rcfile", "resourcefile.rsc", "-add"]
>	end
>
>
>As to starting existing scripts ... you could possibly do:
>
>	#!perl
>	@ARGV =3D ("mailboxname", "-outdir", ":outputpath",
>		"-rcfile", "resourcefile.rsc", "-add");
>	do 'mhonarc';

I tried both methods and they both work. THANKS!

But... there's still a problem.

Either script is launching MacPerl and  MHonArc, but MHonArc still 
displays the "command line" dialog (the arguments that the scripts 
send are not listed).

If I simply click ok on the command line window, then MHonArc runs 
using all the correct options.

So MHonArch received all the right options, but it still puts up the 
command line dialog which I have to click "OK" on. Is there any way 
to suppress the command line dialog when it's not needed? It kind of 
kills the automation aspect of all this. (although it's a great 
improvement to actually typing in the commands, of course)


>Or you could, if you have MPW perl set up, do:

I don't have MPW now, and I think installing MPW is too much for just 
this one application, unless it's fairly easy to do?


-Steve
0
steve_rothman_list
1/29/2001 8:57:23 PM
At 11:27 am -0500 29/01/01, Steve Rothman wrote:

>Sorry for what I'm positive is a dopey question, but I'm a rank 
>beginner at Perl in general and MacPerl in particular. I *have* 
>spent literally hours going through the archives of this list and 
>the MacPerl documentation trying to help myself, and I see fragments 
>of answers but nothing that has yet worked for me...
>
>I am using a wonderful Perl script called MHonArc 2.5 -- in fact 
>this is the same script that is used to create the MacPerl archives 
>on the web.
>
>(For info: http://www.nacs.uci.edu/indiv/ehood/MHonArc/doc/mhonarc.html )
>
>My procedure for using MHonarc on my Mac is this:
>
>  * Start MacPerl (5.2.0r4)
>
>  * I do Command-R to run a script, then I select the  MHonArc script
>
>  * I get a prompt for a command line, then I type:
>     mailboxname  -outdir  :outputpath  -rcfile  resourcefile.rsc  -add
>
>This works great, and MHonArc speedily creates a set of web pages 
>for me based on my Eudora mailbox.
>
>My problem is that I can't figure out how to automate it, and I'll 
>need to do it once a day.  On a unix system one would just type 
>something on the shell like:
>
>       #  mhonarc  mailboxname  -outdir  :outputpath  -rcfile 
>resourcefile.rsc  -add
>
>And so it would be really easy to make a shellscript to do this.
>
>I've tried writing an AppleScript, and I can launch MacPerl and 
>MHonArc from AppleScript just fine, but I can't figure out how to 
>simulate typing in the command line. (There are a ton of posts on 
>this topic in the MacPerl list archives, with many different 
>solutions to this issue, but none of the solutions seem to work for 
>me.)
>
>In any event, it seems a little silly to use AppleScript for this - 
>but I don't even know how to get started to write a simple MacPerl 
>script that will start up another existing script and feed it the 
>correct command line options.

You could perhaps write a script something like this:

	#!perl
	# Put an alias to 'mhonarc' in the folder 'lib'
	chdir("path:to:MHonArc2.4.7:lib");
	@ARGV = ("path:to:System Folder:Eudora Folder:Mail Folder:In");
	require "mhonarc";

When you run this script it will in turn run the script 'mhonarc' 
with the parameters in '@ARGV'.

However when 'mhonarc' finds out that the OS is MacOS it will put up 
an 'Ask Dialog' asking for the command line parameters. You don't 
want this since the command line parameters are already stuffed into 
'@ARGV'. To suppress the call alter line 66 of file 'mahamain' to 
read:

	require 'osinit.pl';  &OSinit(1);
         ------------------------------^

(There must be a more elegant way to do this but for the moment I 
can't see it.)

Other options can be pushed into @ARGV in the usual way e.g.:

	@ARGV = ('help');
or	@ARGV = ('-add', 'path:to:mail');


and so on.

I'm not sure how automatic you want to make the whole thing, but it 
might be appropriate to save the script above as a droplet. A double 
click would then launch MacPerl (if it's not already running) and 
create the web pages.

I hope this helps towards what you want to do.

Alan Fry

0
ajf
1/29/2001 8:58:20 PM
At 15:57 -0500 01.29.2001, Steve Rothman wrote:
>>  >I've tried writing an AppleScript, and I can launch MacPerl and
>>>MHonArc from AppleScript just fine, but I can't figure out how to
>>  >simulate typing in the command line.
>
>>
>>	tell app "MacPerl"
>>		do script ["mhonarc", "mailboxname", "-outdir", �
>>			":outputpath", "-rcfile", "resourcefile.rsc", "-add"]
>>	end
>>
>>
>>As to starting existing scripts ... you could possibly do:
>>
>>	#!perl
>>	@ARGV = ("mailboxname", "-outdir", ":outputpath",
>>		"-rcfile", "resourcefile.rsc", "-add");
>>	do 'mhonarc';
>
>I tried both methods and they both work. THANKS!
>
>But... there's still a problem.
>
>Either script is launching MacPerl and  MHonArc, but MHonArc still
>displays the "command line" dialog (the arguments that the scripts
>send are not listed).
>
>If I simply click ok on the command line window, then MHonArc runs
>using all the correct options.
>
>So MHonArch received all the right options, but it still puts up the
>command line dialog which I have to click "OK" on. Is there any way
>to suppress the command line dialog when it's not needed? It kind of
>kills the automation aspect of all this. (although it's a great
>improvement to actually typing in the commands, of course)

Hrm; what is the code in MHonArch that brings up the command line dialog?


>>Or you could, if you have MPW perl set up, do:
>
>I don't have MPW now, and I think installing MPW is too much for just
>this one application, unless it's fairly easy to do?

It is not hard, no.  It takes a little bit of work, and it has a lot more
uses in the future.

-- 
Chris Nandor                      pudge@pobox.com    http://pudge.net/
Open Source Development Network    pudge@osdn.com     http://osdn.com/
0
pudge
1/29/2001 10:50:46 PM
At 3:57 pm -0500 29/01/01, Steve Rothman wrote:
>So MHonArch received all the right options, but it still puts up the
>command line dialog which I have to click "OK" on. Is there any way
>to suppress the command line dialog when it's not needed? It kind of
>kills the automation aspect of all this. (although it's a great
>improvement to actually typing in the commands, of course)

At 5:50 pm -0500 29/01/01, Chris Nandor wrote:
>Hrm; what is the code in MHonArch that brings up the command line dialog?

Like I said yesterday, to suppress the Dialog, alter line 66 of file 
'mahamain' to read:

	require 'osinit.pl';  &OSinit(1);
         ------------------------------^

Why? MacPerl::Ask() is called at line 102 of 'osinit.pl':

	$cmdLine = &MacPerl::Ask( "Enter command line options:" );

_unless_ $noOptions is defined. (See lines 96, 97, 98 osinit.pl).

One way of setting $noOptions to 'true' is the modification of line 
66 of 'mahamain' above. As I said there may well be a more elegant 
way to do this.

At 3:57 pm -0500 29/01/01, Steve Rothman wrote:
>I don't have MPW now, and I think installing MPW is too much for just
>this one application, unless it's fairly easy to do?

It's quite big. I tend to agree it would be taking a sledge hammer to 
crack a nut to install MPW just to run MHonArc. The MacPerl 
application works fine after all.

Alan Fry
0
ajf
1/30/2001 10:58:12 AM
>>>So MHonArch received all the right options, but it still puts up the
>>>command line dialog which I have to click "OK" on. Is there any way
>>>to suppress the command line dialog when it's not needed? It kind of
>>>kills the automation aspect of all this. (although it's a great
>>>improvement to actually typing in the commands, of course)
>>
>>Hrm; what is the code in MHonArch that brings up the command line dialog?
>
>Like I said yesterday, to suppress the Dialog, alter line 66 of file 
>'mahamain' to read:
>
>	require 'osinit.pl';  &OSinit(1);
>         ------------------------------^


Too cool, this worked!  (BTW the file involved is "mhamain" not 
"mahamain"). Thanks a ton to Chris and Alan for the great help.


>Why? MacPerl::Ask() is called at line 102 of 'osinit.pl':
>
>	$cmdLine = &MacPerl::Ask( "Enter command line options:" );
>
>_unless_ $noOptions is defined. (See lines 96, 97, 98 osinit.pl).
>
>One way of setting $noOptions to 'true' is the modification of line 
>66 of 'mahamain' above. As I said there may well be a more elegant 
>way to do this.

Here are two sections of the "osinit.pl" script.:

>##	OSinit() checks what operating system we are running on set
>##	some global variables that can be used by the calling routine.
>##	All global variables are exported to package main.
>##
>##	Variables set:
>##
>##	    $MSDOS	=> Set to 1 if running under MS-DOS/Windows
>##	    $MACOS	=> Set to 1 if running under Mac
>##	    $UNIX	=> Set to 1 if running under Unix
>##	    $VMS	=> Set to 1 if running under VMS
>##	    $DIRSEP	=> Directory separator character
>##	    $DIRSEPREX	=> Directory separator character for use in
>##			   regular expressions.
>##	    $PATHSEP	=> Recommend path list separator
>##	    $CURDIR	=> Current working directory
>##	    $PROG	=> Program name with leading pathname component
>##			   stripped off.
>##
>##	If running under a Mac and the script is a droplet, command-line
>##	options will be prompted for unless $noOptions argument is
>##	set to true.
>##

<snip>

>     ##	Ask for command-line options if script is a Mac droplet
>     ##		Code taken from the MacPerl FAQ
>     if (!$noOptions &&
>	defined($MacPerl::Version) &&
>	( $MacPerl::Version =~ /Application$/ )) {
>
>	# we're running from the app
>	local( $cmdLine, @args );
>	$cmdLine = &MacPerl::Ask( "Enter command line options:" );
>	require "shellwords.pl";
>	@args = &shellwords( $cmdLine );
>	unshift( @ARGV, @args );

Alan's suggestion to change the mhamain.pl from the original


>require 'osinit.pl';  &OSinit();

to

>require 'osinit.pl';  &OSinit(1);

Seems to work perfectly well, but I'm wondering if would somehow be 
better or more appropriate to change something in osinit.pl instead?

Curious to hear your opinions, then I'll forward this whole 
conversation to the MHonArc people...

Once again, thanks to everyone, my  basic problem seems very solved 
at this point! -Steve
0
steve_rothman_list
1/30/2001 3:36:51 PM
Reply:

Similar Artilces:

Re: [MacPerl] automating script that uses command line?
----- Original Message -----=20 =46rom: "Steve Rothman" <steve_rothman@creoscitex.com> | My problem is that I can't figure out how to automate it, and I'll=20 | need to do it once a day. On a unix system one would just type=20 | something on the shell like: |=20 | # mhonarc mailboxname -outdir :outputpath -rcfile=20 | resourcefile.rsc -add |=20 | And so it would be really easy to make a shellscript to do this. |=20 | I've tried writing an AppleScript, and I can launch MacPerl and=20 | MHonArc from AppleScript just fine, but I can't ...

How to pass command line arguments to an extension using a command line on MacOS
I am developing an extension that processes some command line options. I want to invoke the Firefox from a command line like this: > ...../firefox -myarg1 -myarg2 I am running into a problem on Mac OS. When I run such command when there is no FireFox running it works fine. However if I run the command again I get an error saying that there is already an instance of Firefox running and only one instance can run at a time (paraphrasing here). I have tried to use the -remote option but no luck. Does anyone know how to solve this problem? Does anyone know if invoking of chatzill...

How to pass command line arguments to an extension using a command line on MacOS?
I am developing an extension that processes some command line options. I want to invoke the Firefox from a command line like this: > ...../firefox -myarg1 -myarg2 I am running into a problem on Mac OS. When I run such command when there is no FireFox running it works fine. However if I run the command again I get an error saying that there is already an instance of Firefox running and only one instance can run at a time (paraphrasing here). I have tried to use the -remote option but no luck. Does anyone know how to solve this problem? Does anyone know if invoking of chatzill...

How to take command line argument and use it to run an upgrade script.
I'm a perl newby. I'm looking on taking a command line argument from STDIN and use it for input to a script that upgrades software. Any examples would be greatly appreciated. Thanks ===== Jeffrey T. Collins jtbaca@yahoo.com __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ On Thu, 2004-01-22 at 18:14, Jeff Collins wrote: > I'm a perl newby. > I'm looking on taking a command line argument from > STDIN and use it for input to a script that upgrades > sof...

command line scripts
Does anyone know how I can run command line scripts using asp.net and vb? I am mostly interested in using the iis command line script iisweb.vbs to create and delete websites. I would like to have a form that, when submited, runs the the command line script using the form values. Thanks Look at the Process class in the System.Diagnostics namespace. You can also use the class to redirect output into a stream for reading from your application. You might need to twiddle with security settings in order to have the permissions to do this from an ASP.NET app, impersonation is one option. Feel...

Command line scripting
This question is about normal ASP, not ASP.Net. My question is can make ASP script to run it without any browser accessing the page (Command line scripting). I need this because I want to run ASP scripts regularly executed without any user requesting the page. Thanks for your time. you don't want ASP. you want WSH get the windows scripting docs : http://msdn.microsoft.com/scripting/ will append to this post when I get to work - got to rush now. jRTFM - straight talk for web developers. Unmoderated, uncensored, occasionally unreadableJason Brown - MVP, IIS OK, back at th...

Command Line commands
Is there a list of commands that can be used at the NetWare server and at the Windows workstation command line for ZFD 4.? I can't find them in the documentation or on the knowledgebase apart from ZENVER. Thanks in advance for any replies. Spamaddress@spam.com, > Is there a list of commands that can be used at the NetWare server and at > the Windows workstation command line for ZFD 4.? > To control what? NAL? - Anders Gustafsson, Engineer, CNE6, ASE NSC Volunteer Sysop Pedago, The Aaland Islands (N60 E20) Novell does not monitor these forums officiall...

Command line commands
Within a PowerBuilder application, how do I create an association so that all files with no extension are opened with notepad? I am using InsertFile command. I know we can use the command line 'assoc' command but I don't know how to include it in PowerBuilder code. I am using PowerBuilder 6.5 Thanks Mangala You could probably do that with the run function. However, you should be careful because most directories don't have extensions. I don't know what kind of behavior that will cause. Mike ...

how to use command line parameters
------_=_NextPart_001_01C58890.7A431714 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable command line: =20 $perl man.pl manish =20 =20 =20 perl script =20 #!/usr/bin/perl; ($inputfile) =3D @ARGS; =20 Could anyone tell me how to accept the commandline parametes this does = not seem to work. =20 Regards, Manish U ------_=_NextPart_001_01C58890.7A431714-- Manish Uskaikar wrote: >command line: > >$perl man.pl manish > > > >perl script > >#!/usr/bin/perl; >($inputfile) = @AR...

How to use command-line switches...
------_=_NextPart_001_01C33C0D.531C65FF Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I have a case where I need to use a command-line switch such as -X or /= x Could anyone help me with information as to how I read this into a p= erl script and test it - along the lines of "if "/x" then..." ?? I've= searched but can't seem to find any concrete example that a newbie like= me can use as a sample. Thank you!! Portions of this message may b= e confidential under an exemption to Ohio'...

How use command line parameters?
Hi! I want to get a file name from command line, like this: somecommand.pl filename How I can realize it? How it realizes with several files: somecommand.pl file1,file2... fileN? Thanks. -- -----------! My blessing! Ramis. ! -----------! http://www.samtan.fromru.com mailto: samtan@fromru.com * Ramis <Ramis@karaaltyn.ru> [2002-04-15 22:14 +0200]: > I want to get a file name from command line Perl pushes then to a list named @ARGV . So you can access them with any function that operates on lists, like foreach, shift, pop or just $ARGV[n] . > How it...

[MacPerl] arguments in command line
Hi, This must be an FAQ, but being at an early stage, I don't even know where FAQ's are located. I want to test a Perl Script on a Mac, and then run it on a remote unix box. It shall be called with arguments on the command line. The script starts with: #!/usr/local/bin/perl -w test1.pl $in = $ARGV[0]; # expecting test1.pl print $in, "\n"; result: # Use of uninitialized value. What should I change ? Thanks. (Macperl 5.13r2) Arguments in the perl command line are handled well in the MPW tool version of MacPerl. They behave just like UNIX. (Well - I'l...

AFPBIND script command line
Forgot to enable AFP when creating cluster enable volumes with Console 1 Adding the AFPBIND and AFPUNBIND commands in load and unload script will be enough ? (NFAP for Mac already installed). Thanks Mirliton I can't say definitively for NW6, but this worked for me with NW6.5. On Tue, 11 Nov 2003 14:46:22 GMT, mirliton@myrealbox.com wrote: >Forgot to enable AFP when creating cluster enable volumes with Console 1 >Adding the AFPBIND and AFPUNBIND commands in load and unload script will >be enough ? (NFAP for Mac already installed). >Thanks >Mirl...

CPAN and command line scripts
Hello. http://search.cpan.org/~ruz/RT-Action-NotifyGroup/ has script 'sbin/rt-notify-group-admin.in' that has POD and this POD is what end-user wants more then other docs. What requirements should I satisfy if I want search.cpan.org to show link on script's POD in Documentation section of the dist page? I think that +x flag can help, but don't want to release new version just to check it. Best regards. Ruslan. --oXNgvKVxGWJ0RPMJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Rusla...

Web resources about - automating script that uses command line? - perl.macperl

Velocity Europe Conference 2013, Addy Osmani: Lightning Demo: Automating The Removal Of Unused CSS ...
http://velocityconf.com The best way to minimize the latency caused by stylesheet loading is to cut down on the CSS footprint; an obvious way ...

Tufin in Australia: software-defining datacentres and automating channel
Under APAC director Tim Murphy, Network security management and risk assessment company, Tufin, is rapidly expanding its Australian operations. ...

Identity and Access Governance: Automating repetitive, consuming account management tasks
As organizations try to rein in technology budgets, IT staff members are constantly tasked with doing more and providing better services, all ...

Incremental SDN: Automating Network Device Configuration
The definition of Software Defined Networking (SDN) continues to broaden, today including functions such as configuration automation and orchestration. ...

Automating Test Design in Agile Development Environments
Antti Huima loves algorithms and his talk at Star West 2010 reflected this. And that is actually a good thing. If V-Model is constructing a ...

Automating with convention: Introducing sub
When I started my on-call shifts , we had pretty little in the way of automation for day-to-day issues. Tasks like SSH ’ing into our cluster, ...

If This Then That (IFTTT) launches iOS app for automating service directives
If This Then That (IFTTT) today launched an iPhone app version of its popular service for automating simple actions/services. The video above ...

New Yahoo, AOL, Microsoft Pact: Automating Direct Sales
Yahoo has begun automating the sale of its premium ad slots, so that an advertiser or its agency would be able to purchase the portal's top-tier ...

Moto Maker now automating iCloud-to-Google switching
Moving from an iPhone to Moto X? Motorola's hoping to make things a lot easier


Resources last updated: 1/11/2016 10:00:23 PM