Is there a way to give a process a chosen number, so i can "brek" it afterwards without findng out it's number first?
I'm starting a process within a DOS script (a samba share) which depends on the server being online.
smbfs has a timeout which is nice end easy enough to use for mounting the share (once it becomes available in the LAN), but if the server goes down again, the smbfs share will stay on screen, albeit not available (which is annoying).
I'd like to "break" it's process by checking for it's online status...the checking i have figured out, but breaking an unknown process number is impossible.
The process in my example is called Process 16: Loaded as command: smbfs '//PHENOMIIX4/SambaShare/'
and there is always at least one more smbfs process running.
...Also "break" has an undocumented (AmigaOS4 wiki) option called "name". I guess it's meant to break processes by the name? That doesn't work though.
To the best of my knowledge, the user has no control over the process numbers, so that's not an option.
You should be able to use the NAME option, though.
Try entering "help break" in the shell, it should give you the documentation.
Specifically these sections:
---8<--- A process can be signalled by giving a name or a wildcard pattern. The name will be compared against the program's name (including its full path, if available) and the program name (excluding the path), if the first test did not produce a match. ---8<---
- and:
---8<--- 1> BREAK NAME "DIR#?"
sets the Ctrl-C attention flag of all processes whose names begin with the letters "DIR"; this would include the "DIR" program, for example. ---8<---
It'll probably work if you used T:PID instead of PIPE:PID
It was sort of a joke answer anyway. It might work, but looks unprofessional :)
The Run command will give you the process number of the command it's running, so "Run >T:PID programhere" will send the process number to T:PID, although you probably want to run the server and return to shell, hence "Run <>NIL: Run >T:PID programhere"
Edit: I don't know what I was thinking with two Runs 1 is sufficient.
Actually i was using your line and peeped it up a bit so i get the process number and be able to break the process afterewards.
It does work, but there is a small nuisance.
If i start the line from shell it works and writes everything i need to T:, but if i put the same line in a DIS script a blank file is written instead of the information.
A line like "Run <>NIL: Run >T:PID program" is going to need a very small delay before you read T:PID, because it's going to exit to shell first before T:PID has been written. I haven't tried it in an AmigaDOS script myself, but that's probably the issue.
Unfortunately i can't use that idea, because it will be the process number from the very first start.
But i need it inside my script, as there is the possibility that the program is closed from within the script and reopend on demand,
If i use your run line inside the script, it will obviously kill all the following IF loops that rely on the output of the program start (e.g. a timeout error).
Hrmpf...need to try and rewrite it completely in arexx with file I/O then
For some reason I thought there was a difference between 1 and 2 Runs. You can use Run >T:PID program >T:Out.txt and the process ID will output to T:PID, return to shell when T:PID has been written (no delay needed) and T:Out.txt will contain the output from the program. You won't know when the program has finished running though. PIPE: might come in handy if it makes ReadLn() wait until there's new data.