I'd like to run and configure a process similarly to a daemon from a script.
My shell is zsh emulated under Cygwin and the daemon is SFK, a basic FTP server.
For what matters here, the script
startserv.sh can be drafted as follows:
#!/bin/sh read -s -p "Enter Password: " pw user=testuser share=/fshare cmd="sfk ftpserv -user=$user -pw=$pw -usedir $share=$share" $cmd &
After running the script
startserv.sh, it stops (ends?) without showing any prompt, then:
CTRL+C ends both the script and the background job process;
Hitting Enter the script ends the process remains in the background.
Anyway I can see it only via
ps and not
jobs, so, when I want to close the process, I have to send a brutal
kill -9 signal, which is something I'd like to avoid in favour of CTRL+C.
An alternative would be running the whole script in background. 'Would be', but the
read command is unable get the user input if the script is run as
Note that I need an ephemeral server, not a true daemon: that is, I want the server process to run in the background, after the script ends, to perform simple interactive shell tasks (with a virtual machine guest), but I don't need the process to survive the shell; therefore
nohup seems not appropriate.