Operating System - HP-UX
1753829 Members
8841 Online
108806 Solutions
New Discussion юеВ

Re: Scripting issue where it wants a tty

 
Krishna Prasad
Trusted Contributor

Re: Scripting issue where it wants a tty

Would it be a bad thing if you send it to /dev/console ?
Positive Results requires Positive Thinking
Bernie Vande Griend
Respected Contributor

Re: Scripting issue where it wants a tty

Thanks Mark and Ron. I've tried every method of directing output I can think of including those you suggest, but it doesn't help.

Example:
My_tool </dev/console 2>&1
logoff user=myuser
ENDIT

Still get the no tty error wherever I direct the output.
Seems to me I need to trick the input somehow so it thinks I'm on a tty or /dev/console, etc, but I'm not sure if that's possible.
Ye who thinks he has a lot to say, probably shouldn't.
Mark Greene_1
Honored Contributor

Re: Scripting issue where it wants a tty

have you tried it like this:

My_tool <TERM=vt100 # or whatever is appropriate
logoff user=myuser >/dev/tty 2>&1
ENDIT

HTH
mark
the future will be a lot like now, only later
Paula J Frazer-Campbell
Honored Contributor

Re: Scripting issue where it wants a tty

Hi

Lateral thinking

Run a cronjob on another server to telnet to the server with the script - login and fire up the script and when finished leave.


Paula
If you can spell SysAdmin then you is one - anon
Bernie Vande Griend
Respected Contributor

Re: Scripting issue where it wants a tty

Thanks Mark. Think of MY_tool as a program with its own language. Once you execute it, you can no longer use shells commands inside it, so the syntax you propose would not work.

Paula, thanks. Your idea was was my final option, which should work. In fact, I could even use the cron on the server itself to use expect and then telnet back to itself. I don't really like this idea because I'd have to put the password in the script and its very unelegant. But it should work and if I really need to automate this, its probably my only choice left. When I get the time to install TCL/TK/expect I'll give this a try.
Ye who thinks he has a lot to say, probably shouldn't.
Jordan Bean
Honored Contributor

Re: Scripting issue where it wants a tty

Bernie, tell us again what type of program MY_tool is. Is it a unix shell script? Or is it a compiled binary? If it's a binary, this won't work.

If it's a shell script, it may be possible to circumvent the tty restriction without actually providing a tty and without modifying the script. Examine the script and look for the use of the commands tty or pty.

If it's a POSIX shell script, then it may check like this:

tty || exit

if tty -s
then
continue()
else
echo "Not a tty"
fi

if ! tty -s
then
echo "Not a tty"
exit
fi

if [ -t 0 ]
then
echo "You are out of luck here"
exit
fi

If it is using tty or pty, alias them to true or false (whichever is appropriate) before sourcing the script:

alias tty=true
. script <
Bernie Vande Griend
Respected Contributor

Re: Scripting issue where it wants a tty

Sorry Jordan, it's a binary from a 3rd party vendor. This would be a piece of cake if My_tool was a shell script. Your information is good (as is everyone else's above) if you're dealing with scripts or cleaning up /etc/profile or .profile.
Ye who thinks he has a lot to say, probably shouldn't.
Mark Greene_1
Honored Contributor

Re: Scripting issue where it wants a tty

have you contacted the vendor to see if there are specific environment variables or command line options you can set?

just a thought,
mark

btw, which vendor?
the future will be a lot like now, only later
Bernie Vande Griend
Respected Contributor

Re: Scripting issue where it wants a tty

Thanks Mark. I mentioned earlier that the vendor- FileNet, says there is no way to run the script non-interactively, it wasn't designed for that. And they have no options to get around it either. Thus I opened this post to see if I could use a UNIX shell trick instead.
Ye who thinks he has a lot to say, probably shouldn't.
A. Clay Stephenson
Acclaimed Contributor

Re: Scripting issue where it wants a tty

Hi Bernie:

After reading all this, I can see two options:

Plan A: Relatively easy but messy (and you've already mentioned it) Loop output from one tty port to another.

Plan B: Elegent but technically difficult. Write and install a pseudo-tty device driver so that the isatty(0) function returns 0 and thus the application thinks stdin is a tty device (because it is). The idea is that your can write to this pseudo device and store your input and then the read read from the buffer.

I did have to do something very much like this many years ago but I haven't done it in the HP-UX world.

Food for thought, Clay
If it ain't broke, I can fix that.