LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 03-12-2007, 11:16 PM   #1
xviddivxoggmp3
Member
 
Registered: Feb 2004
Location: scanf
Distribution: Redhat Enterprise 4.4 AS
Posts: 236

Rep: Reputation: 30
terminal validation


i have a need to write a script in csh that detects what terminal you are sitting at prior to allowing execution of the script. this has to test to make sure it is only executable at this specific terminal.
i have tried the following, but it doesn't work.
please any guidence would be appreciated.
Code:
set stMasterTerminal = "/dev/pts/2"
set stUserTeriminal = `tty`

if ($stMasterTerminal == $stUserTerminal) then

#execute some code

else

    echo "Invalid Terminal"
    exit 1

endif
 
Old 03-13-2007, 09:46 AM   #2
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
First off, it works (after the obvious changes).

When posting, don't just say "it doesn't work". In general, state the expected and actual results. This has been said hundreds of times.

In your case, I guess as follows. Tell me whether I'm right or wrong.
Expected: either no output or "Invalid Terminal", depending on the tty.
Actual: "stUserTerminal: Undefined variable."

That error happens because of a typo, and that's the obvious change:
Code:
set stUserTeriminal = `tty`
By the way, why do you "have a need to write a script in csh"?
 
Old 03-13-2007, 12:09 PM   #3
xviddivxoggmp3
Member
 
Registered: Feb 2004
Location: scanf
Distribution: Redhat Enterprise 4.4 AS
Posts: 236

Original Poster
Rep: Reputation: 30
i made the correction, but still it does not work.
i'm still getting an error
Quote:
0: event not found
I need it to detect if an invalid terminal is being used to execute a script.
i would rather code this in korn instead of csh, but i have been requested to do it in csh.
please if someone has any ideas on how to get this to work. i would appreciate the help.
 
Old 03-13-2007, 12:21 PM   #4
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Again: did I guess your expectations right?

Code:
0: event not found
This doesn't make sense. Are you sure you're running exactly the script above, less that one "i"?

Check your PATH. You might think you're running your script but executing something completely different?
(E.g., novices name their program "test", type "test" with much anticipation, and execute /usr/bin/test.)
How do you invoke the script?
 
Old 03-13-2007, 12:24 PM   #5
xviddivxoggmp3
Member
 
Registered: Feb 2004
Location: scanf
Distribution: Redhat Enterprise 4.4 AS
Posts: 236

Original Poster
Rep: Reputation: 30
script being ran as ./security.scr
executed in my current working directory

Code:
#!/bin/csh

set verbrose
set xtrace

if ($#argv != 0)then
        echo "This script requires 0 arguements"
        echo "Usage:  $0"

        exit 1
endif

set stMasterTerminal = "/dev/pts/3"
set stUserTerminal = `tty`
eval stUserTerminal

echo $stMasterTerminal
echo $stUserTerminal  #these echos show the values as identical

if ($stMasterTerminal == $stUserTerminal) then



        exit 0

else



        exit 2

endif
 
Old 03-13-2007, 12:44 PM   #6
xviddivxoggmp3
Member
 
Registered: Feb 2004
Location: scanf
Distribution: Redhat Enterprise 4.4 AS
Posts: 236

Original Poster
Rep: Reputation: 30
sorry to bump the thread, but does anyone have any idea that might help.
the changes i made in my script are very minor and i do not know what this
Quote:
0: event not found
error is or how to get the script to work.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Your Validation scbops Linux - Newbie 1 12-27-2006 05:09 AM
php validation logic spoody_goon Programming 5 01-14-2006 07:31 PM
Genuine Windows Validation microsoft/linux General 1 10-11-2005 10:43 PM
email address validation rblampain Linux - Security 8 09-21-2005 02:20 AM
Validation Makaveli.2003 Programming 1 05-06-2002 08:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 11:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration