When the users login they can use the shift 1 (!) sequence to shell out of the greeting screen. I do not want the users to have the power to do this. Can anyone tell me how to disable this function?
When they logon onto our system they receive a greeting message telling them the lastest news,in order to view the message we are using the more command to stop it from scrolling. They then hit a key to proceed to the software. Some users are hitting The ! key to shell out, instead of continueing to the software.
Unfortunately, the unix file views such as more and pg include the ability to invoke a shell using !. I know of no way to turn off.
Long ago, one of my customers faced this same problem. I wrote a small file viewer utility (written in "C" using curses) to solve this problem. If you like, I'd be happy to post it in this forum. It won't do you any good unless you have a "C" compiler on your unix box.
try the 'less' utility, you can compile a version that doesn't allow shell escapes Mike
________________________________________________________________
"Experience is the comb that Nature gives us, after we are bald."
Is that a haiku?
I never could get the hang
of writing those things.
I do not know what the "Less" utility is. Is there some documentation i can look at to try this. I am open to all ideas, I just am not up to date on Unix.
First, less is now available on most modern $nix systems. From the command line, perform a:
man less
Below is my pgit utility. It was developed for ASCII files greater with lines greater than 80 chars. The pg and more utilities wrap. This one allows the user to move to the right, left, down, and up.
To compile:
cc pgit.c -lcurses -o pgit
This program has been compiled under SCO Open Server, Solaris, and HP-UX. If the curses library isn't installed, obviously, this fails.
If you have problems cutting and pasting this, I'll gladly email it to you.
Let me know if you have any questions.
Regards,
Ed
cut here
/*
progrm name: pgit.c pg/more replacement. view an ascii file
Author: Ed Schaefer
Usage:
pgit <filename> # is NOT a pipe.
To compile:
cc pgit.c -lcurses -o pgit
This is a curses program using a "pad". Some old curses libraries
(such as xenix) may not support the "pad".
This is free software. No warranty is granted or implied. Use at your
own risk or reward.
#define KEY_JUMP 5 /* Number of columns to move with an arrow */
#define PAGE_LEN 66 /* Number of rows in a report page */
#define SCROLL_DOWN 'd' /* Alt Key to scroll down */
#define SCROLL_UP 'u' /* Alt Key to scroll up */
#define SCROLL_RIGHT 'r' /* Alt Key to scroll right */
#define SCROLL_LEFT 'l' /* Key to scroll left */
#define PAGE_UP 'p' /* Key to page up */
#define PAGE_DOWN 'n' /* Key to page down */
#define PAGE_RIGHT 'R' /* Page Right */
#define PAGE_LEFT 'L' /* Page Left */
FILE *in, *fopen();
WINDOW *wpad, *cmdwin, *exewin, *blankit;
void alter();
int x = 114;
int y = 260;
#define YLEN 260
int xpad = 0;
int padptr = 0;
int winwid = 36;
int winlen = 19;
int totlines;
#define is_uppercase(x) ((x >= 'A' && x <= 'Z') ? 1 : 0)
#define to_lowercase(x) ((is_uppercase(x)) ? x + 'a' - 'A' : x)
struct node
{
int padno; /*identify the pad number*/
int nlines; /*number of lines in the pad number*/
long poffset; /*offset into ascii file to read for each pad */
int accum; /*total number of lines in file */
struct node *next, *prev; /*next and previous nodes in linked list*/
};
typedef struct node node_t;
struct head /*header node*/
{
int length; /*current length of list */
/*pointers to first, last, and current elements*/
struct node *first, *last, *current;
};
typedef struct head head_t;
head_t *createl();
node_t *inst_node();
node_t *new_list;
char buffer[YLEN];
char tbuffer[60];
head_t *nlist; /*define head of new list */
fseek(in,xoff,0);
while(1)
{
fgets(buffer,YLEN,in);
cnt++;
if(feof(in) || cnt > x)
break;
blank_buf(buffer);
update_pad();
}
if(cnt < x)/*null out any rows from previous page*/
{
strcpy(buffer,spacebuf);
for(i=cnt; i <= x; i++)
update_pad();
}
}
void update_pad()
{
mvwaddstr(wpad,xpad,0,buffer);
xpad++;
}
void show_pad(xrows,xcols)
int xrows, xcols;
{
prefresh(wpad,xrows,xcols, 1,1,19,78);
}
void run_cmd()
{
int c,d;
int bflag=0;
int line_no;
char page_no[5];
show_line();
mvwaddstr(exewin,1,0,"Page : n=Scrn Dn R=Scrn Right Dn ->,d=Scroll Dn ->,r=Scroll Right b=BOF"
mvwaddstr(exewin,2,0,"q = Quit p=Scrn Up L=Scrn Left Up ->,u=Scroll Up <-,l=Scroll Left e=EOF"
sprintf(page_no, "%d", 1);
mvwaddstr(exewin, 1, 8, page_no);
wrefresh(exewin);
while(1)
{
d = wgetch(exewin);
if ((d != PAGE_LEFT) && (d != PAGE_RIGHT))
c = to_lowercase(d);
else
c = d;
switch(c)
{
case KEY_BREAK:
bflag=1;
break;
case 'q':
bflag=1;
break;
case KEY_RIGHT:
case SCROLL_RIGHT:
if(update_cord('R', KEY_JUMP))
show_pad(mainrow,maincol); /*show pad */
break;
case KEY_LEFT:
case SCROLL_LEFT:
if(update_cord('L', KEY_JUMP))
show_pad(mainrow,maincol); /*show pad */
break;
case KEY_DOWN:
case SCROLL_DOWN:
if(update_cord('D', 1)){
show_pad(mainrow,maincol); /*show pad */
}
break;
case KEY_UP:
case SCROLL_UP:
if(update_cord('U', 1))
show_pad(mainrow,maincol); /*show pad */
break;
case PAGE_UP: /*page up*/
if(update_cord('u',winlen))
show_pad(mainrow,maincol); /*show pad */
break;
case PAGE_DOWN: /*page down*/
if(update_cord('d',winlen) )
show_pad(mainrow,maincol); /*show pad */
break;
case PAGE_RIGHT: /*page right */
if(update_cord('O',winwid))
show_pad(mainrow,maincol); /*show pad */
break;
case PAGE_LEFT: /*page left */
if(update_cord('B',winwid))
show_pad(mainrow,maincol); /*show pad */
break;
case 'b': /*home postion*/
padptr = 1;
new_list = nlist->first;
xpad = 0;
mainrow = 0;
maincol = 0;
set_pad(0L);
show_pad(0,0);
break;
case 'e': /*end postion*/
if(nlist->length == 2)
{
mainrow = nlist->last->nlines - winlen;
}
else
{
padptr = nlist->length - 1;
new_list = nlist->last->prev;
mainrow = new_list->nlines - winlen;
xpad = 0;
set_pad(new_list->poffset);
}
maincol = 0;
show_pad(mainrow,maincol);
break;
default:
break;
int update_cord(xchar,lenl)
char xchar;
int lenl;
{
int bufit, pivot;
int c;
/*determine whether to use the end of the pad or the total number of
lines read into the pad*/
/*if(totlines < x)
pivot = totlines;
else
pivot = x;
pivot = nlist->current->nlines; */
/* move right -> R = one KEY_JUMP, O = one page */
if(xchar == 'R' || xchar == 'O')
{
if(maincol == y) /* We are at the end, so don't move */
return(0);
bufit = maincol + lenl;
if(bufit <= y) /* Move full lenl chars */
maincol += lenl;
else
maincol = y; /* < lenl chars left, move to the end */
return(1);
}
/* move left -> L = one KEY_JUMP, B = one page */
if(xchar == 'L' || xchar == 'B')
{
if(maincol == 0) /* At the beginning, so don't move */
return(0);
/*blank everything at the end of the line to allow old data over screen to
be blanked out when the cursor movement keys are used*/
void blank_buf(buf)
char *buf;
{
int len,i;
/*append a node to the linked list*/
int app_node(pno, pset, list)
int pno;
long pset;
head_t *list;
{
node_t *new;
if(new = inst_node(pno,pset,list->last,NULL))
{
if(list->length) /*if list is not empty*/
list->last->next = new; /*link in the new node */
else
{
list->first = new; /*set first pointer to new*/
list->current = new; /*set the current only once */
}
list->last = new; /*link in the new node*/
list->length++; /*update list length*/
return(TRUE);
}
else
return(FALSE);
}
/*instantiate new node*/
node_t *inst_node(pno,pset,prev,next)
int pno;
long pset;
node_t *prev, *next;
{
node_t *new;
hehe - "Why use more, when you can use less?"
I first heard of less back in 1995. I thought it was a joke. But now, it is my file viewer of choice. If you don't have less pre-installed on your OS, search the internet. Believe me, you will be glad you did.
I didn't realize that you could compile a version that would remove some functionality. Would that make it even less of less? Einstein47 ("For every expert, there is an equal and opposite expert." - Arthur C. Clarke)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.