Parsing Root password inside a C shell script

Hello everyone,
I want to check how long a remote computer is running (e.g. with the command uptime or who - b)
The check should be done during login from none root user by a script which is called from .cshrc. My script works fine if I login as root but I want that everybody get the information at login.
My question now can I place the root password inside the script that the command will not ask for the root password.
I know it is not save to put the password inside the script but in this case it will be ok.
The system is AIX 4.3.2.0 and sudo is not installed (And I not want to installed)
Any help are really appreciated

I just checked (on Linux) and who -b works for non-root users:

neo:~$ who -b
         system boot  2019-01-30 00:24

You cannot run who -b from a non-root user account on AIX?

1 Like

Sorry , maybe I not explained clearly
There is our local host (IBM 6000) and there are around 15 User and they can use uptime and who -b on this Maschine. But there is one computer connected to this local host and on this Maschine the users are not defined, on this only root has access and can perform the command uptime etc
With kind regards

Well, it's probably me, but I still do not understand what you are trying to do exactly and why you think you need to put a root password in a shell script.

If you need to get stats from a machine to non-root users on a connected machine, most people would create a guest account and get up that guess account properly.

There are 100s of ways to approach this problem which would not require "root passwords in shell scripts" but the again, it's hard to understand what exactly your configuration and what you are trying to do and why, at least for me.

1 Like

If there is the rstat service enabled then you can remotely query the uptime

rup remotehostname
1 Like

Hello Neo
Thanks a lot for your reply.
You are right there are maybe 100 ways to solve this problem.
Since I not an expert in AIX therefore I would take the easy way. I not want to install anything Suff like sudo , ssh rstat.
Here I try to explain one more time what I want to do.
If user A login with his private account the system shall tell him automatically if the local Maschine up for more than x days (the trigger x are defined in the script) if the time greater than x a message will appear and tell the user the system should be rebooted ASAP otherwise nothing will appear. That works fine with the local Maschine, but with the remote Maschine when I use �rsh remote uptime� I got the message permission denied.
With your Idee with the guest user it is not done automatically the user has to think ever time he login to su to the guest user account, but I want it fully automatically.
BTW I know it is a really bad solution to put the root password inside a script but I think for me it is the easiest way to solve this and keep in mind all the users on this maschine knows the root password. But for normal operation they will login with his private account.
Next time when I in the office I will check the command rup recommendation from the guy
With kind regards