Presumably there are logs kept on the target instance that contain the STDOUT and STDERR of the StackScript when run. If so, where? If not, why not?
Sorry if I missed the answer and it's here. Couldn't find it, in that case.
StackScripts don't log by default, but you can enable logging in a variety of ways such as using
logger or something like
exec >/root/stackscript.log 2>&1 There's an excellent post here with some StackScript tips and tricks.
Stackscripts launch with stdin, stdout, and stderr connected to the console (whether that is /dev/console or /dev/ttyS0 is pretty irrelevant, as writing to either of them will go to the same place). If you want to save logs in your Stackscript, then you can either redirect program output to the logfile, or if your script is shell, you can use exec to replace the script's stdout and stderr with the file descriptor for the log file, which would then be inherited by any programs the script calls. (You can also do this replacement in other languages, generally speaking.)
@dwfreed - you got the gist of my question, and your suggestion regarding exec is right on, but it doesn't work. Possibly because the filesystem is initramfs when the machinations with getty are performed?
Anyway, as you suspected, what I would like to do is something like shebang:
#!/bin/bash >/root/SSout 2>/root/SSerr
and that would work in a normal bash script, but it doesn't work here. Nor do the lines:
Worse, attempts like these to redirect cut off display in lish (hence my thought output might be going to initramfs).
I chose /root because that's where the StackScript shows up when creation is complete. In case there was a permissions problem, I also tried /tmp to no avail.
The getty is not launched (and thus the stackscript) until long after the root filesystem has been switched from the initramfs to the real root filesystem. Shebang lines are not processed for redirections, as that is a function of shell, not program execution. Adjusting the exec command @mjones gave for your particular file paths, this is what the start of your script could look like:
#!/bin/bash exec >/root/SSout 2>/root/SSerr dowork
Aye lads, twas the syntax. Thank ye for bein' there in the wee hours of me timezone!
Thanks @mjones and @dwfreed - still looking at why my first attempt with @mjones syntax didn't work but it did just now exactly as in @dwfreed's quote. Might have been the wee hour. And thanks for the lucid dialog @dwfreed.