asked question about script before missed ansewr..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting asked question about script before missed ansewr..
# 1  
Old 09-05-2004
CPU & Memory asked question about script before missed ansewr..

linux fedora core2
Smilie i am trying to write a script to clear, date, pwd and tty a linux termnal or konsole.. when I test the tty against $0 i am, getting a premission denied on the terminal that I am trying to printf to.. I tried using an awk command, test condition, an if then fi clause, but either all the terminals respond similiarly or I get permission denied on /dev/pts/?....
what am I doing wrong and why won't the script work.. and is there a way to find out the file for the particular terminal number that I am looking for and change the permissions.. which I have not been able to do..
thanx moxxx68
Smilie

Last edited by moxxx68; 09-07-2004 at 04:42 AM..
# 2  
Old 09-05-2004
How about posting the script that you have so far? Would be easier to trouble shoot if you posted it.
# 3  
Old 09-05-2004
Computer scripts

Smilie
this may look easy.. infact the first time I tried it last year right when i first started to use linux it worked.. on one of the linux systems that I have had.. I have had 4 systems include this one 3 old laptops to expriment with an o.k desktop and now a new HP pavillion laptop finally to work on bigger things.. but after trying the programm the first time, the second and third time i got confused.
# ! /bin/sh
# .filename

script 1
function print () { clear; pwd; date; tty; }
`tty`="TTY"
if [ $TTY = "/dev/pts/3 ]
then
print
echo "experimental terminal"
else
print
fi


script 2 (of several )

{ clear; pwd; date; tty; `tty`="TTY" | awk '{if($0 == /dev/pts/3)print "experimental terminal"}; }

or

function print () { clear; pwd; date; tty; }
if ($PWD == such and such dir)
then
print
echo " experimental terminal" >/dev/pts/3
else
print'
fi
SmilieSmilie

Last edited by moxxx68; 09-05-2004 at 03:03 PM..
# 4  
Old 09-07-2004
This bit...

`tty`="TTY"

...seems wrong. If you want to store the name of the terminal, use...

TTY=`tty`

Also, "print" is not a good name for a function as it may conflict with a shell builtin with the same name.

Incidentally, if you just want to send a message to the terminal, then you can use the special file: /dev/tty, e.g....

echo "Howdy" > /dev/tty
# 5  
Old 09-07-2004
> .dev/tty !?

Smilie the problem with this :
> /dev/tty is that I want it to look like this..
etc etc > /dev/tty/(3) and even that gives me a permission denied message... infact it isn't responding..

i tried
# !/bin/sh
# file
TTY=`tty`
function fun () { clear; date; pwd; tty }
if [ $TTY == "/dev/tty/3" ]
then
fun
printf " etc etc " > /dev/tty/3
else
fun
fi

i guess I am just being obsessed I'll drop it for a couple of weeks and come back to it /...
thanx for the input!
i am lacking experience and prectice so i guess I try again later

thanx moxxx68;;

ps...by the way ygor i commend you on your skills!
# 6  
Old 09-07-2004
Computer actually!

Smilie actually it worked !
I have no words to tell you how amazed I am at the fact that i missed it by a mile trying to script it in when it was so simple..
{ clear; date; pwd; tty; printf " etc etc" > /dev/pts/3 }
thanx a million..
thanx moxxx68
Smilie Smilie Smilie Smilie
# 7  
Old 09-07-2004
MySQL here is the new code

Smilie
# !/bin/sh
# .clear

TTY=`tty`
function fun { clear; pwd; date; tty; }

if [ "$TTY" == "/dev/pts/3" ]
then

fun
echo "experimental terminal" > /dev/pts/3
else
fun
fi

the other code had a bug in it.. but this worked.. this is major jump for me since I am new to scripting... thanx again..
thanx moxxx68Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Can I trace who asked for reboot

Hi, I have an unexpected reboot happening on a Debian 9.9 server. Yesterday 2019-12-01 at 8:30:34 a reboot happened without me or my team being aware: /var/log/syslog:Dec 1 08:30:34 xxxx shutdown: shutting down for system reboot /var/log/syslog:Dec 1 08:30:34 xxxx init: Switching to... (4 Replies)
Discussion started by: chebarbudo
4 Replies

2. Shell Programming and Scripting

Find missed numbers

I have a file as follows: 1 3 7 12 78 ... 999998 1000000 I want to find out all numbers not in the file above and put into another file like 2 4 5 6 8 9 10 (13 Replies)
Discussion started by: dtdt
13 Replies

3. Linux

Apache folder missed

Hi, I am confused on apache service. Please advice me There is no apache directory in my linux box. Even I cant find out httpd.conf file also. But If browse my Hostname in Internet Explor, I can able to apache service there. Please How it is working .. This file is available in... (1 Reply)
Discussion started by: Mani_apr08
1 Replies

4. Shell Programming and Scripting

variable not getting asked....

Hello all, I am trying to pass or trying to get a variable assinged...but seemed like i am doing something wrong here.... so lets say abc.txt(spool the output out) is my file, where i am doing select * Fro mv$version inside my DB and getting some info. -/home/oracle/logs >cat abc.txt SQL>... (1 Reply)
Discussion started by: abdul.irfan2
1 Replies

5. AIX

Career Advice Asked

Dear All i am working on windows plattform and i am interested in Aix so i have done IBM Aix certification, can you please suggest Aix filed is good for my carrier,currently i am working as Desktop admin edit by bakunin: please understand that the question you raised has nothing to do with the... (1 Reply)
Discussion started by: manzur13
1 Replies

6. HP-UX

vgchgid missed one disk

Hi, Suppose I have 3 disks c0t0d0, c0t0d1, and c0t0d2 all with the *same* VGID. I then run: # vgchgid /dev/rdsk/c0t0d0 /dev/rdsk/c0t0d1 (notice I *accidentally* skipped the third disk!) How would I fix this so that all 3 disks have the same VGID again? I'm looking for step-by-step... (7 Replies)
Discussion started by: apra143
7 Replies

7. Shell Programming and Scripting

I thought I asked the question before but I haven't sorry

:D could any one answer my previous question... just looked through logg and found no such question that I had asked.. please any input would help \.. :confused: (2 Replies)
Discussion started by: moxxx68
2 Replies

8. UNIX for Dummies Questions & Answers

Simple Question ever asked

How do I cahnge my plan under my profile? (5 Replies)
Discussion started by: D3adRabbit
5 Replies
Login or Register to Ask a Question