• *NIX shell scripting question (or possibly other scripting methods)

    From Khelair@VERT/TINFOIL to All on Saturday, November 10, 2012 08:43:37
    Can any shell script wizards out there tell me if there is a way using 'sh' or 'ksh' to enclose a block of script in some kind of structure that will try to execute something, wait for a predetermined amount of time, and then if there is no user input on the keyboard for that period of time, execute another block of code or else just skip what was going on entirely? I'm trying to set up my different runlevels so that if my machine ends up rebooting or being rebooted for some reason while I'm out of town it'll skip mounting of the encrypted partitions; I really still want to have that bit called from the startup scripts, though, instead of having to log in and su to root and all of that crap after booting to mount the encrypted partitions.
    TIA

    -=-
    Opinions expressed are not necessarily those of the owners or management of this corporeal rotting porksuit.
    -=-



    ---
    þ Synchronet þ Tinfoil Tetrahedron : telnet bismaninfo.hopto.org 8023 : http:8080
  • From Deuce@VERT/SYNCNIX to Khelair on Sunday, November 11, 2012 17:29:28
    Re: *NIX shell scripting question (or possibly other scripting methods)
    By: Khelair to All on Sat Nov 10 2012 08:43 am

    Can any shell script wizards out there tell me if there is a way using 'sh' or 'ksh' to enclose a block of script in some kind of structure that will try to execute something, wait for a predetermined amount of time, and then if there is no user input on the keyboard for that period of time, execute another block of code or else just skip what was going on entirely?

    I'm not sure exactly what you're asking for... a prompted input with a timeout?

    ---
    http://DuckDuckGo.com/ a better search engine that respects your privacy.
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Khelair@VERT/TINFOIL to Deuce on Monday, November 12, 2012 11:06:19
    Re: *NIX shell scripting question (or possibly other scripting methods)
    By: Deuce to Khelair on Sun Nov 11 2012 17:29:28

    Can any shell script wizards out there tell me if there is a way usin 'sh' or 'ksh' to enclose a block of script in some kind of structure that will try to execute something, wait for a predetermined amount of time, a then if there is no user input on the keyboard for that period of time, execute another block of code or else just skip what was going on entirel

    I'm not sure exactly what you're asking for... a prompted input with a timeo

    Yeah, I think you've got the right idea. Basically I'm looking for a way in my OpenBSD and one of my Linux systems to make the startup scripts prompt for a password to unlock encrypted partitions, but to timeout if nobody is around so that it will still finish the booting sequence and just not provide access to the encrypted partitions if I'm not available to supply the passphrase. Using a USB key as the solution is not an alternative I can go with, either, because I do not want that USB key liable to be seized at any point and used without my consent.
    After a little bit of research somebody on a DOC BBS that I'm a member of ended up mentioning that bash's 'read -t' function might be able to do what I'm looking for; it dies and returns failure after the specified number of seconds if there has been no keyboard input. I was hoping to be able to stick with the native 'sh' or 'ksh' shells, but if I have to call bash for a small segment of the shell script it might still not be such a bad alternative.

    -=-
    Opinions expressed are not necessarily those of the owners or management of this corporeal rotting porksuit.
    -=-



    ---
    þ Synchronet þ Tinfoil Tetrahedron : telnet bismaninfo.hopto.org 8023 : http:8080
  • From Deuce@VERT/SYNCNIX to Khelair on Tuesday, November 13, 2012 11:24:17
    Re: *NIX shell scripting question (or possibly other scripting methods)
    By: Khelair to Deuce on Mon Nov 12 2012 11:06 am

    After a little bit of research somebody on a DOC BBS that I'm a member of ended up mentioning that bash's 'read -t' function might be able to do what I'm looking for; it dies and returns failure after the specified
    number of seconds if there has been no keyboard input. I was hoping to be able to stick with the native 'sh' or 'ksh' shells, but if I have to call bash for a small segment of the shell script it might still not be such a bad alternative.

    read is a shell builtin for every Bourne style shell I've seen. It's external to csh and tcsh I think though.

    If not, the systen should have a read command too in /usr/bin.

    ---
    http://DuckDuckGo.com/ a better search engine that respects your privacy.
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)