- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Pseudo Terminal Session Number/Name Options
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2007 04:11 AM
08-31-2007 04:11 AM
Servers to a new HP-UX 11 Server.
On the current Server, my telnet session have the naming convention:
pts/t0 thru t9
pts/t10 thru t99
On the new new Server, the telnet sessions have the naming convention:
pts/t0 thru t9
pts/ta thru tz
pts/tA thru tZ
pts/tab thru ttzb
etc
This is causing a problem with temporary files we use to run reports.
Is there a way I can change the new Server to use a same naming
convention as the current Server?
The server HP-UX versions are slightly different revisions.
Thanks in advance for any help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2007 04:20 AM
08-31-2007 04:20 AM
Re: Pseudo Terminal Session Number/Name Options
You need to change your script. Use the pid ($$) of the process you run to create a unique temporary file for the duration of your process. Do something like:
#!/usr/bin/sh
typeset MYNAME=${0##*/}
typeset TMPDIR=${TMPDIR:=/var/tmp}/${MYNAME}.${$}
mkdir -m 700 ${TMPDIR} || exit 1
trap 'rm -rf ${TMPDIR}' EXIT
...[your script follows on here...]
This creates temporary files in '/var/tmp' in a directory named that of the basename of your process. If the pid of your script is appedned to the directory created to make it unique.
The trap runs whenever your script exits, and remmoves the directory and any files therein created by your script.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2007 04:36 AM
08-31-2007 04:36 AM
Re: Pseudo Terminal Session Number/Name Options
We have legacy applications using COBOL. So using temporary files are actually coded into the application to always use the same directory and use the terminal name (to, t50, etc) in the name of the temporary file so it's unique for that user. I inherited this. This is coded into many places, so it's going to be horrendous to track it all down and change it.
Right now it's running on HPUX 11.00, so the device name under dev/pts are t0 - t99, etc.
However, on 11.11 they are t0-9, ta-z, then it goes tA-Z.
Even worse, the code for the temporary files doesn't take case into consideration, so the temporary files for a user with terminal name ta and another user with terminal name tA create the same temporary file name (it's all made lowercase).
So this wasn't a problem on 11.00, as the terminal names were all numbers with a 't' prefix'.
Any help you guys could give me on this will be VERY much appreciated.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2007 04:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2007 04:55 AM
08-31-2007 04:55 AM
Re: Pseudo Terminal Session Number/Name Options
Do you think I could go into dev/pts and just delete any device names that I know will cause a problem. For example, all device names with capitals (tA-Z).
If you think that would work, would I just:
rm tA
or would I need to use
rmsf tA
Thanks again for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2007 05:00 AM
08-31-2007 05:00 AM
Re: Pseudo Terminal Session Number/Name Options
> Do you think I could go into dev/pts and just delete any device names that I know will cause a problem. For example, all device names with capitals (tA-Z).
You could ('rm or 'rmsf'), but they could always be re-generated by 'insf'. Once again, this is "fixing" the wrong thing!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2007 05:12 AM
08-31-2007 05:12 AM
Re: Pseudo Terminal Session Number/Name Options
The Server it's currently on is 7 years old, and I'm worried about hardware problems.
The COBOL apps, sadly, are mission critical to the company. The company is small, so doesn't have a Unix admin as such, just Windows admins trying their best.
The COBOL programmers here inheritied the mess. We can certainly make sure the temp file creation is done correctly on any of the reports we know about. Trouble is there are hundreds, literally. So we'll fix it, and to the right thing in the long run.
The kernal parameters on the new Server have nstrtel = 512. I wouldn't normally come close to 100 simultaneous connections, so if we delete any device names in dev/pts with capitals we'll be ok I hope.
No one here is going to change any of the kernal parameters once it's gone live, or run insf. So is there any other way those device files under /dev/pts will be recreated?
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2007 05:16 AM
08-31-2007 05:16 AM
Re: Pseudo Terminal Session Number/Name Options
Here is one approach that should work.
Create a script that will capture the major/minor device number tuples of /dev/pts/t*, sort them, old name, and proposed new name to a file.
Now read that list and first remove the old device node and create a new node with the same major/minor device tuples but with the new name.
Script 1:
---------------------------------------
#!/usr/bin/sh
typeset DIR=/dev/pts
typeset SAVEFILE=/var/tmp/ptslist
ls -l ${DIR}/t* | \
awk '{print $6,$5,$NF}' | sort | \
awk -v dir=${DIR} '{printf("%s %s %s %s/t%d\n",$1,$2,$3,dir,++knt)}' > ${SAVEFILE}
-----------------------------------------
Script 2:
-----------------------------------------
#!/usr/bin/sh
typeset SAVEFILE=/var/tmp/ptslist
cat ${SAVEFILE} | while read MINOR MAJOR OLDNAME NEWNAME
do
echo "Removing ${OLDNAME}"
# rm ${OLDNAME}
echo "Creating ${NEWNAME} c ${MAJOR} ${MINOR}"
# mknod ${NEWNAME} c ${MAJOR} ${MINOR}
done
-----------------------------------------
Remove the commented lines for the rm and mknod commands when you feel confident.
NOTE: Backup the /dev/pts directory before you do this so that you can get yourself out of trouble almost as fast as you got yourself in. I intentionally divided this into two parts with a file so that you could edit the file if you wish and also the file could be used to recreate the original device nodes if needed. Users should be off the system while you do this and you must do this from the console. May The Force be with you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2007 05:25 AM
08-31-2007 05:25 AM
Re: Pseudo Terminal Session Number/Name Options
Thanks so much for spending the time to detail it out so well for me!
Very much appreciated!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2007 05:35 AM
08-31-2007 05:35 AM
Re: Pseudo Terminal Session Number/Name Options
11.00 = obsolete and unsupported
11.11 = current but becoming mature
11.11 has a *LOT* of changes and differences. In the area of pseudo terminals, the names have been changing because the drivers are migrating tp streams-based model, hence the kernel parameters pty, nstrpty and nstrtel. The man page for pty lists the classic pty names, while the man page for pts shows the streams naming (shown at the end of their man pages)
As mentioned, these names are created automatically when you change nstrtel or npty or nstrpty (using SAM). insf -e (or insf -s or -p options) will create missing device files. So you'll have to be quite careful about using insf -e.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2007 10:16 AM
09-04-2007 10:16 AM
Re: Pseudo Terminal Session Number/Name Options
I ran the scripts, and they ran fine. I uncommented out the rm and mknod parts. Ran on the console, all appeared to run fine.
After it was done the contents of /dev/pts was as expected. All looked good.
However, when I telnet into the Server I get:
telnetd: /dev/pts/ta: No such file or directory
I have bounced the Server.
I can back it out, I've just be establishing and breaking a mirror each time. So, I have an easy back out.
Do you have any idea what else needs to be changed?
Thanks in advance.
Gareth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2007 10:50 AM
09-04-2007 10:50 AM
Re: Pseudo Terminal Session Number/Name Options
It's time to fix the problem rather than trying to fix the symptoms; fix that stupid COBOL ---- and this was a state-of-the-art stupid method of generating temporary file names.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2007 11:51 AM
09-04-2007 11:51 AM
Re: Pseudo Terminal Session Number/Name Options
It's just not realistic to change all the reports in the next 1.5 weeks, which is when we were needing to go live. There are 100's of them. Programmers, sys admins all inherited this mess, sadly.
There seems to be the same amount of special files in /dev as there are in /dev/pts. Could the same name change need to take place there too?
We're running 11.11.
Thanks again for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2007 03:14 PM
09-04-2007 03:14 PM
Re: Pseudo Terminal Session Number/Name Options
You could try but I think the kernel is just keeping track of the free device by a number then it translates that into the character string. And you by removing those devices, get that missing /dev/pts/ta for 10.
>JRF: typeset TMPDIR=${TMPDIR:=/var/tmp}/...
Any reason you use typeset? You want these to be local to a function?
Also, the correct syntax is ":-", not ":=". When you use ":=", you typically use it as:
$ YY=${XX:=abc} # set two variables
$ : $(XX:=abc} # only set XX
With ":-", you don't have to worry about setting TMPDIR twice. ;-)