Additional Info

Show me your flowchart and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won't usually need your flowchart; it'll be obvious. (Fred Brooks, The Mythical Man Month)

This post tagged:


Restrict script to console use

A customer asked for a way to prevent a certain shell script from execution by SSH - it apparently it is supposed to be run only at the console.

One choice is to examine 'tty'. Something like this, perhaps:

#!/bin/bash case `tty` in /dev/tty*) echo "ok";; /dev/pts/*) echo "No";exit 0; esac echo "Will proceed"

Or perhaps one of the SSH variables can be tested:

#!/bin/bash test -n $SSH_CLIENT && exit 1 echo "Will proceed"

However, that $SSH_CLIENT will not be set if you "su -" to another user after logging in with ssh, so you may need to use the more direct test.

Got something to add? Send me email.

(OLDER) <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> Restrict script to console use

Increase ad revenue 50-250% with Ezoic

More Articles by

Find me on Google+

© Anthony Lawrence

Kerio Samepage

Have you tried Searching this site?

Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us