I have been having an issue with the new motorola rf scan guns opening up too many sessions at once. It seems they will open a new connection for no reason, leaving the old one in the background and the user has no idea it is happening. To combat this, I have added the following code to the logon profile script that is supposed to see if the user's IP address is already logged on and if it is, it will kill the old session and let the new one on:
after that part it executes the main program all the users run.
It seems to work but every now and then one of the user accounts that uses this profile script will open up another session anyway.
As you can see, I am a beginner and I am sure there is a much more elegant way to do this, but I am still learning. Can anyone tell me why it could be that it works for most users but not others?
Not bad for a beginner. I'm surprised the line with the "if" isn't a problem, however. You need a space between [ and $IPCNT.
Second, it's better to do a kill -1 $PID than kill -9. The former will try to close the child processes of a shell, while the latter may result in hung child processes. Better yet, don't just kill the process, but kill the process group. This is the second field from "ps -j $PID". So you can do:
It might also be necessary to wait for two seconds before continuing the script, giving the system a chance to perform the kills before the script continues. Adding "sleep 1" I think might be enough.
Also, you don't have to do a cat every time -- grep, sed, awk can all take a filename as an argument -- but maybe using cat helps you keep things straight. Also, no need to do a grep and then an awk. Awk does both. (sed -n works similarly.)
My system's "whoami" doesn't work the same as yours, otherwise I could test a similar script. But fix the problem with the bracket
Hi
I have numerous files names
product_host_result_B1000842.txt
product_host_result_B1000847.txt
product_host_result_C1000842.txt
product_host_result_C1000848.txt
etc. I need them renamed so that the 'product_host_result' becomes 'output_product_host' but the rest of the filename is... (6 Replies)
Hi All,
I am calling a shell script from another shell script, however, it only executes part of it (the echo commands only). What could be some causes for that?
For example:
ShellScriptA.sh:
...
...
...
. ShellScriptB.sh
ShellScriptB.sh contents:
echo date
echo... (7 Replies)
Hi All,
I tried killing a bunch of scripts. They seem to have worked because
ps -ef | grep -i SCRIPT_NAME is not showing them but the logs are getting populated and jobs in the script are getting done.
How do I really kill them or atleast see the process running?
Thanks
Sumeet (12 Replies)
Hi All,
I tried creating a .profile file but it is not working even after exiting the session.
But before that I will give a quick background.
I log into UNIX(SUN - ksh) and then SUDO to another user. After that I change DIRECTORY. In this DIRECTORY I tried creating the profile file but it... (4 Replies)
I am using Solaris ...
I have some settings in my .profile and in .profile iam calling some scripts.
After i logged in to that box if i gave "bash" and proceed with my shorcuts(alias) are not working . (3 Replies)
Two boxes we just reloaded to use as a two node HACMP cluster to insure our software is compatible.
Install disks we received at our library on 5/2009 AIX 5.3-ML10
For sake of argument names ibmaix1 and ibmaix2
On both:
ibmaix1# oslevel -r
5300-10
.rhosts files with 600 permissions... (0 Replies)
I have X4500 and I created a user. I wanted to give him root privileges and for editing the sudoers files I typed visudo sudoers. But it said visudo command not found. After googling I found that we need to set path in etc/profile. I edited that and put the following command
... (3 Replies)
Hi ,
I have modified .profile and after that i ran it as .profile. Now no command i working even ls is not working
When i type ls , it is showing that -ksh not found
I tried to run as . $home/.profile , it is saying as permission denied .
How can we do that .. any idea..
Thanks... (2 Replies)
Hi,
I have logged into a Sun Solaris machine( Putty -telnet ) , which got hung.
now I need to kill the process - ksh
When I tried to kill like : kill -9 <pid of ksh> , it is not giving any error , but the process is not getting killed...
Here is what I did
$ps -fu shihab
... (5 Replies)