English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 24 January 2023, 23:02   #1
Wepl
Moderator
 
Wepl's Avatar
 
Join Date: Nov 2001
Location: Germany
Posts: 869
NP_Arguments

Is there any magic necessary with dos.SystemTagList and NP_Arguments?
I don't get it working.
I like to call a script with arguments. But it doesn't get any args.

The NP_Arguments are terminated with newline + 0.
I also tried to add tag SYS_Input + Open("NIL:", OLDFILE).
Calling program is started from CLI or Workbench, no difference.

script:
Code:
.key ARG1
.bra {
.ket }

echo {ARG1}
script works file when called directly
Wepl is offline  
Old 25 January 2023, 09:49   #2
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,247
Lots of confusion here. NP_Arguments is for CreateNewProc(), not for System() (thus, the NP_ name, which stands for NewProc). System() takes an entire command line, actually pretty much a shell script. So what System() does is that it launches a new shell, and provides to this shell a "script" that consists of the argument string of System().

Other than that, the usual conditions arise. The script should have its S bit set so the shell passes it over to "Execute". Note that the ".dot" cmmand syntax is actually interpreted by the Execute binary, not by the shell.

Last but not least: What does *not* work is to put the ".dot" commands directly into the System() command, again because System() just launches a shell, and the shell knows nothing about these commands. Only C:Execute does.
Thomas Richter is offline  
Old 25 January 2023, 14:40   #3
Wepl
Moderator
 
Wepl's Avatar
 
Join Date: Nov 2001
Location: Germany
Posts: 869
Quote:
Originally Posted by Thomas Richter View Post
Lots of confusion here. NP_Arguments is for CreateNewProc(), not for System() (thus, the NP_ name, which stands for NewProc).
Autodocs for SystemTagList tell:
Code:
       The tags are passed through to CreateNewProc() (tags that conflict
	with SystemTagList() will be filtered out).  This allows setting
	things like priority, etc for the new process.  The tags that are
	currently filtered out are:

		NP_Seglist
		NP_FreeSeglist
		NP_Entry
		NP_Input
		NP_Output
		NP_CloseInput
		NP_CloseOutput
		NP_HomeDir
		NP_Cli
   INPUTS
	command - Program and arguments
	tags    - see <dos/dostags.h>.  Note that both SystemTagList()-
		  specific tags and tags from CreateNewProc() may be passed.
Quote:
Originally Posted by Thomas Richter View Post
System() takes an entire command line, actually pretty much a shell script. So what System() does is that it launches a new shell, and provides to this shell a "script" that consists of the argument string of System().

Other than that, the usual conditions arise. The script should have its S bit set so the shell passes it over to "Execute". Note that the ".dot" cmmand syntax is actually interpreted by the Execute binary, not by the shell.

Last but not least: What does *not* work is to put the ".dot" commands directly into the System() command, again because System() just launches a shell, and the shell knows nothing about these commands. Only C:Execute does.
The S-flag is set. As I told the script works fine on the CLI.

Anyhow, I think I will concatenate the args to the command and avoid NP_Arguments.

Last edited by Wepl; 25 January 2023 at 14:46.
Wepl is offline  
Old 25 January 2023, 17:17   #4
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,247
Quote:
Originally Posted by Wepl View Post
Autodocs for SystemTagList tell:
Yes, those are the tags that are actively filtered out, but that does not mean that all the other tags are functional. Just remember what System() does: It runs into CreateNewProc(), starting a new process, but the seglist of this process is the (specified, user or system) shell. The shell segment does not expect arguments in a0/d0 and the input file handle as usual command line tools do, it simply does not care about them. Rather, the shell uses a somewhat awkward (and as of 3.2, a little bit less bit still awkward) startup message to receive its intstructions, and this message reflects (to some degree) the arguments to Sytem().



Even then, what should the shell do with arguments that are not really meant for its own process, but for a script that still needs to be loaded? These are not arguments that should go to the shell, but rather to its first (or all?) commands to load.



Instead, the command or script to be executed, along with its full arguments, quoted according to the shell syntax, need to be provided as string as first argument to System(). This string is then "magically" converted to a command stream that is interpreted (applying all the wierd syntax rules) of the shell.


Thus, if you have any arguments to pass, make sure you quote them correctly, and escape quotes within quoted strings correctly, and so on.

Quote:
Originally Posted by Wepl View Post
Anyhow, I think I will concatenate the args to the command and avoid NP_Arguments.
This is almost, but not entirely correct. Consider the four arguments


foo
bl"a
hi there
wh*at no"w


then concatenation will not give the right result. You need to quote anything that contains blanks, and escape any special character, but only those that got quoted. Thus:


foo bl"a "hi there" "wh**at no*"w"


would be correct. Getting these things straight can be medium nightmare as the quotation rules of the shell are rather "bizarre".
Thomas Richter is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 18:00.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07053 seconds with 14 queries