Article View: comp.sys.amiga.tech
Article #10351Re: AmigaLine #D1, Disconnecting a program such that you can EndCLI
From: Arne Nordmark
Date: Wed, 23 Nov 1988 10:57
Date: Wed, 23 Nov 1988 10:57
109 lines
3520 bytes
3520 bytes
In article <8811211839.AA12164@postgres.Berkeley.EDU> dillon@POSTGRES.BERKELEY.EDU (Matt Dillon) writes:
>Gunnar gno@stacken.kth.se Writes:
>>In my version of AmiCron I set pr_ConsoleTask to DeviceProc("null:")
>>and now it doesn't requires a window to run!
>
> Try entering a crontab entry which does this:
>
> "run list"
>
> Does that work? If so, you've just solve all my problems!
Well, I use ARP in my AmiCron and it barfs on the Run command.
But instead I wrote a test program called DevRun that I've included in this
posting. DevRun lets you run a command with any pr_ConsoleTask you like.
Your example "run list" works great with my null: device.
(I don't think I've solved *all* your problems though :-)
Execute (or is it Run?) seems to use the pr_ConsoleTask for all its IO
including the program it spawns. So if you say
DevRun "Run List" null:
everyting, including Run's own output goes to neverland. (i.e. null:)
Here is the code. Tryit out on my null: device wich should arrive in
comp.sources.amiga soon.
Good luck! -Gunnar
/***************************************************************************
*
* devrun.c Example program that runs a command from
* an alternative "console"
*
* Lattice compile:
* lc -L DevRun
*
* Manx compile:
* cc devrun
* ln -o DevRun devrun.o -lc
*
*
* Usage: DevRun "commandline" [device]
*
* examples:
* DevRun "Run List" null:
*
* Runs the command "Run List" from my null: device
*
* DevRun Date
*
* Runs the command "Date" from the default console
* (completely useless in other words)
*
* DevRun "Date > Now" null:
*
* Runs the command "Date" from my null: device
* The output redirected to the file Now
*
* Author:
* Gunnar Nordmark
* Nora strand 5
* S-182 34 DANDERYD
* SWEDEN
*
* gno@stacken.kth.se (stacken.kth.se!gno@uunet.uu.net)
* gno@SESTAK.BITNET
*
***************************************************************************/
#include <exec/types.h>
#include <libraries/dosextens.h>
#include <stdio.h>
LONG Execute();
struct Task *FindTask();
struct MsgPort *DeviceProc();
main(argc, argv)
int argc;
char **argv;
{
struct Process *proc=(struct Process *)FindTask(NULL);
APTR old_device_proc=proc->pr_ConsoleTask; /* Save the old console */
APTR new_device_proc;
char *device;
LONG ret;
if (argc<2 || argc >3) {
fprintf(stderr, "Usage: DevRun \"commandline\" [device]\n");
exit(RETURN_FAIL);
}
if (argc==3) {
device=argv[2]; /* Get the device process */
new_device_proc=(APTR)DeviceProc(device);
if (new_device_proc==NULL) {
fprintf(stderr, "There's no device-process for %s\n",
device);
exit(RETURN_FAIL);
}
proc->pr_ConsoleTask=new_device_proc;
}
fclose(stderr); /* Get rid of the stderr Open ("*",...) stuff */
ret=Execute(argv[1], NULL, NULL);
proc->pr_ConsoleTask=old_device_proc; /* Restore the old console */
return ret;
}
Technical Details
Message-ID:
<655@draken.nada.kth.se>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!enea!kth!draken!nordmarkReferences:
<8811211839.AA12164@postgres.Berkeley.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!enea!kth!draken!nordmark From: nordmark@nada.kth.se (Arne Nordmark) Newsgroups: comp.sys.amiga.tech Subject: Re: AmigaLine #D1, Disconnecting a program such that you can EndCLI Summary: Example program Message-ID: <655@draken.nada.kth.se> Date: 23 Nov 88 10:57:34 GMT References: <8811211839.AA12164@postgres.Berkeley.EDU> Reply-To: stacken.kth.se!gno@uunet.uu.net (Gunnar Nordmark) Organization: Royal Institute of Technology, Stockholm, Sweden Lines: 109