Sponsored Content
Top Forums Shell Programming and Scripting Automatic su password entry script Post 302884200 by 3therk1ll on Saturday 18th of January 2014 09:46:46 AM
Old 01-18-2014
Automatic su password entry script

Before I start, two things.

1) Yes I know it's bad practice and obomination to all things holy, but I'm not a sys admin at JP Morgan, I'm a hobbyist tooling about in a VM, in my pants, at home.

2) If you are just going to flame for even considering hardcoding a root password, thanks, I get it.

So here goes.
I have the following script:

Code:
#!/bin/bash
clear
echo
whoami
echo
PASS="1234"
expect -c "spawn su
expect -nocase \"password:\" {send \"$PASS\r\" ; interact ; whoami }"
#Scripts exits at this point
echo -ne "Name: "
read name
echo
echo $name

It works fine in that it enters the password and elevates the privileges of the user.
The problem is that it then exits at the marked point and does not continue to the code below.
Any ideas why this is?

Running Backbox 64 Bit in VMPlayer

Last edited by 3therk1ll; 01-18-2014 at 10:47 AM.. Reason: Forgot system details
 

10 More Discussions You Might Find Interesting

1. Programming

/etc/shadow update password entry! ( getspent? )

Hi i just whant to update an password entry in /etc/shadow. But dosen't get it to work. Something is wrong! in this code. What i try do do is if user kalle exist in shadow. I whant it to update it's password for just that entry. #include <stdio.h> #include <errno.h> #include <stdlib.h>... (2 Replies)
Discussion started by: nighter
2 Replies

2. Programming

userpw.h AIX ( delete entry from the shadow password database )

HI i need to delete an entry in /etc/security/passwd. can't find a way to do it with userpw.h api ( AIX ). the passwd file i delete like this. Write all entrys to passwd file except the one we are removing. can't find any function that works like getspent / getpwent do in AIX userpw api.... (4 Replies)
Discussion started by: nighter
4 Replies

3. Shell Programming and Scripting

automating username / password entry

I have a database that contains a list of server names, and the password for the root user on several servers (100+). I need to verify the passwords for each of the servers in an automated fashion because the database continues to grow. All of the users that I'm going to test are ROOT. I can't... (1 Reply)
Discussion started by: jbeck22
1 Replies

4. UNIX for Dummies Questions & Answers

Command to delay password entry - putty connection manager

Hi all, putty connection manager is great but when attempting to sudo or ssh to another box via the post login commands it is subject to issues due to network latency (what happens is that pcm enters the password before the unix box is ready to receive it). Is there any clever way I can make... (1 Reply)
Discussion started by: skinnygav
1 Replies

5. UNIX for Dummies Questions & Answers

grep for password file entry

How would I grep for password file entry without using grep 'username' /etc/passwd? perhaps with who? I want to create alias that will find the password file entry regardless of the user who is using it. I am trying to get the same exact line from the file entry like: Name : Password : UserID... (7 Replies)
Discussion started by: alis
7 Replies

6. UNIX Desktop Questions & Answers

How to grep for password file entry

How would I grep for password file entry without using grep 'username' /etc/passwd? perhaps with who? I want to create alias that will find the password file entry regardless of the user who is using it. Thanks (4 Replies)
Discussion started by: alis
4 Replies

7. Shell Programming and Scripting

loop picks up password for 2 entry...how to avoid that ?

hello all, i am trying to find a better to do what i am doing right now... i have a file called sidlist...which has my database_name and password to the respective database so something like below.. file is called sidlist and entry is below... test, abc123 kes12, abcd12 pss, abcd1234... (5 Replies)
Discussion started by: abdul.irfan2
5 Replies

8. HP-UX

Automatic script to change the UNIX Password

Hi, we have around 50 users and every month we need to change the password manually once its expire. do we have any script to change the password automatically. OS -HP-UX Thanks in advance.. (6 Replies)
Discussion started by: periyasamycse
6 Replies

9. How to Post in the The UNIX and Linux Forums

Help me, write a bash script to delete parent entry with all their child entry in LDAP UNIX server

Hi All, Please help me and guide me to write a bash/shell script on Linux box to delete parent entry with all their child entries. example: Parent is : ---------- dn: email=yogesh.kumar@wipro.com, o=wipro, o=in child is: ---------- dn: cn: yogesh kumar, email=yogesh.kumar@wipro.com,... (1 Reply)
Discussion started by: Chand
1 Replies

10. Solaris

Set password in bash script without manual entry-Solaris 10

Hi I have a root script which is setting up user and his dirs and so on. After I create user and set up all the necessary I have to manually set user password. I try all possible ways what google find me and nothing works for me. If maybe one of you have a solution for my problem it will be... (1 Reply)
Discussion started by: Jaffakeks
1 Replies
asadmin-list-connector-connection-pools(1AS)			   User Commands		      asadmin-list-connector-connection-pools(1AS)

NAME
asadmin-list-connector-connection-pools, list-connector-connection-pools - gets all the connection pools SYNOPSIS
list-connector-connection-pools --user admin_user [--password admin_password] [--host localhost] [--port 4848] [--secure |-s] [--password- file filename] [--terse=false] [--echo=false] [--interactive=true] gets all the connector connection pools. This command is supported in remote mode only. OPTIONS
--user authorized domain application server administrative username. --password password to administer the domain application server. --host machine name where the domain application server is running. --port port number of the domain application server listening for administration requests. --secure if true, uses SSL/TLS to communicate with the domain application server. --passwordfile file containing the domain application server password. --terse indicates that any output data must be very concise, typically avoiding human-friendly sentences and favoring well- formatted data for consumption by a script. Default is false. --echo setting to true will echo the command line statement on the standard output. Default is false. --interactive if set to true (default), only the required password options are prompted. Example 1: Using list-connector-connection-pools asadmin> list-connector-connection-pools --user admin --password adminadmin EXIT STATUS
0 command executed successfully 1 error in executing the command asadmin-create-connector-connection-pool(1AS), asadmin-delete-connector-connection-pool(1AS) J2EE 1.4 SDK March 2004 asadmin-list-connector-connection-pools(1AS)
All times are GMT -4. The time now is 10:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy