Parsing Root password inside a C shell script


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Parsing Root password inside a C shell script
# 1  
Old 08-09-2019
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
# 2  
Old 08-09-2019
I just checked (on Linux) and who -b works for non-root users:

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

You cannot run who -b from a non-root user account on AIX?
This User Gave Thanks to Neo For This Post:
# 3  
Old 08-09-2019
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
# 4  
Old 08-09-2019
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.
This User Gave Thanks to Neo For This Post:
# 5  
Old 08-10-2019
If there is the rstat service enabled then you can remotely query the uptime
Code:
rup remotehostname

This User Gave Thanks to MadeInGermany For This Post:
# 6  
Old 08-11-2019
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Root password expiry script

Hi Guys In red hat linux server is there a way to alert via email when the root password is about to expire ? As per security policy in our environment root password will expire in 90 days. Example : It would be better if we receive a email on 7th november stating that the root password... (1 Reply)
Discussion started by: newtoaixos
1 Replies

2. Shell Programming and Scripting

Switch user without password inside shell

I want to switch to another user without password inside shell. I used the below command and it is not working. sudo su - user1 user1 is not in the sudoers file. This incident will be reported. I'm getting the above message. If I want to add user1 into the sudoers file using... (5 Replies)
Discussion started by: Roozo
5 Replies

3. Shell Programming and Scripting

Running a script as root but with different users inside

Hi All, my script.sh has the below lines, and i need to run the script as root or wam. please tell me if this will work #!/bin/bash sudo -t wam /usr/local/wam/stopwam -r ------- this needs run as wam user /usr/local/web/stopweb -a --- this needs to run as... (18 Replies)
Discussion started by: nanz143
18 Replies

4. Shell Programming and Scripting

Passing username and password to a script running inside "expect" script

Hi I'm trying to run a script " abc.sh" which triggers "use.sh" . abc.sh is nothing but a "expect" script which provides username and password automatically to the use.sh script. Please find below the scripts: #abc.sh #!/usr/bin/expect -f exec /root/use.sh expect "*name*" send... (1 Reply)
Discussion started by: baddykam
1 Replies

5. Solaris

Lost Root Password on VXVM Encapsulated Root Disk

Hi All Hope it's okay to post on this sub-forum, couldn't find a better place I've got a 480R running solaris 8 with veritas volume manager managing all filesystems, including an encapsulated root disk (I believe the root disk is encapsulated as one of the root mirror disks has an entry under... (1 Reply)
Discussion started by: sunnyd76
1 Replies

6. Shell Programming and Scripting

Create script for change root password via SSH

HI I 'm new shall script and unix. I want to create script for change password root by ssh-keygen command . I have 50 servers and I want ot login ot the servers via ssh by type ones password and can login every machines.The script ssh-keygen must ot generate key every weekly than it send new... (2 Replies)
Discussion started by: pellnapook
2 Replies

7. Shell Programming and Scripting

Pass root password through script

I have several clients (over 120) connected to my server. I want to push some patch to all the client using a script which copies the file from the server to a specific path on the client and then installs it. But for installation of the patch, it needs to be done thorough root login on client.... (7 Replies)
Discussion started by: shahdeo
7 Replies

8. Solaris

Solaris 8 - Asks for current root password when trying to change root password.

Hello All, I have several solaris boxes running Solaris 8. When changing root passwords on them, all will simply ask for the new root password to change and of course to re-type the new password. One of the systems however asks for the existing root password before it will display the new password... (8 Replies)
Discussion started by: tferrazz
8 Replies

9. Shell Programming and Scripting

how to change root password using shell script with standard password

Hi Friends. I am new to scripting now i want to change the root password using the script with standard password. which is the easy scripting to learn for the beginner, Thanks in advance. (2 Replies)
Discussion started by: kurva
2 Replies

10. Shell Programming and Scripting

script to change root password

Hi All, I'm looking for a script to change root password for about 200 servers of both Solaris and Linux. I'm not very good at scripting, can anyone share a script if you already have one? :) (3 Replies)
Discussion started by: kvadivel80
3 Replies
Login or Register to Ask a Question