•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,450 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,613 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 3639 | Replies: 1
![]() |
| |
•
•
Join Date: Aug 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Dear all,
I'm doing a script to create a DB user on all machines. I have no way of using sudo. This is for a cross section of sun machines.
i need to ssh to the server, then do a su to root, create the account and then exit. i have done the following:
#!/bin/ksh
## Script to create the mondba account ##
## Date 22Aug2007 ##
PATH=$PATH:/usr/local/bin:
export PATH
ssh -p 15560 user1@jupiter << EOW
su - root 2>&1
useradd -m -d /export/home/mondba -u 33332 mondba
passwd mondba
exit
EOW
exit
Now the problem, I will be prompted for the user1 password but not the root password which i'm supposed to get as a result of the su - i'm executing. Instead i get su: Sorry, looks like it gets timed out. Please give me a hint.
Thanks in advance!
I'm doing a script to create a DB user on all machines. I have no way of using sudo. This is for a cross section of sun machines.
i need to ssh to the server, then do a su to root, create the account and then exit. i have done the following:
#!/bin/ksh
## Script to create the mondba account ##
## Date 22Aug2007 ##
PATH=$PATH:/usr/local/bin:
export PATH
ssh -p 15560 user1@jupiter << EOW
su - root 2>&1
useradd -m -d /export/home/mondba -u 33332 mondba
passwd mondba
exit
EOW
exit
Now the problem, I will be prompted for the user1 password but not the root password which i'm supposed to get as a result of the su - i'm executing. Instead i get su: Sorry, looks like it gets timed out. Please give me a hint.
Thanks in advance!
•
•
Join Date: Aug 2007
Posts: 57
Reputation:
Rep Power: 2
Solved Threads: 2
Try this:
Put your script in a file, addmondba.sh, e.g. As the last (or second last) line of the script, put in "rm -f /tmp/addmondba.sh" to make the script delete itself. Then:
scp -p 15560 addmondba.sh user1@jupiter:/tmp
ssh -t -p 15560 user1@jupiter su root -c "\"sh -x /tmp/addmondba\""
If this doesn't work directly, it should get you closer.
Put your script in a file, addmondba.sh, e.g. As the last (or second last) line of the script, put in "rm -f /tmp/addmondba.sh" to make the script delete itself. Then:
scp -p 15560 addmondba.sh user1@jupiter:/tmp
ssh -t -p 15560 user1@jupiter su root -c "\"sh -x /tmp/addmondba\""
If this doesn't work directly, it should get you closer.
Last edited by Fest3er : Aug 23rd, 2007 at 11:25 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Convert shell script for looping (Shell Scripting)
- Shell Script for Load monitoring! (Shell Scripting)
- ssh changes the way python script behaves (Python)
- Problem with variables in Windows shell script (Windows NT / 2000 / XP / 2003)
- Using find in a bash shell script (Shell Scripting)
- Shell Script for Gnome 2.6 Print Manager. (Shell Scripting)
- How to su properly in a shell script (Shell Scripting)
Other Threads in the Shell Scripting Forum
- Previous Thread: Problem with interpretation of the command line arguments in the script
- Next Thread: value extracting using awk or sed


Hybrid Mode