I am running a shell script it asks for username and password to stop some service, I need to write some script that it will read username and password from my shell script and then sucessfully stop services without prompting username/password query.
You can create a script for stopping and starting instances. You can provide sudo access to the user which don't have access to stop/start services, there you can give nopassword authority to user and by this way script shouldn't ask you username and password then.
It is never recommended to hardcode a password in a script.
Let me give you an example here.
Lets say you are using a user named user1 and services are owned by user user2. So create script for simple stopping and starting services and make owner as user2 (Note: if you don't have permissions for that you can contact root for same).
Then root can give you access for
with non password option there. This means you will be able to run script with user1 (Which actually don't have access to STOP and START services directly) but this
access will give user1 ability to do so.
kindly let me know if I can help you further on same.
When i run below script script it ask me username and password.
That password not belong to any application, it is database password which i need to put in some script so it will not prompt me for username/password and stop service with script.
It is not operating system password, i am telling you, it is database username and password which i need to provide in script so it will not ask me password, it is not related with sudo or any other operating system level thing, it is asking for two arguments username/password which i need to put in script so my service got stop automatically.
---------- Post updated at 03:18 AM ---------- Previous update was at 03:17 AM ----------
Please check my above script i clearly mentioned that example in detail for my script.
I am writing a bash shell script for GarazLab's "WP EMAIL CRAWLER - AUTO SCRAPER & REAL TIME EXTRACTOR". it contains some commands. I want to stop the shell execution as soon as it encounters an error. how to do it? (8 Replies)
Hi All,
Bash shell is being used
Could anyone please let me know - How to trap APPS/Password dynamically in FCP_LOGIN variable in bash shell script?
Thanks for your time
Regards,
a1_win (1 Reply)
I have a strange problem.
I have the following in a cron to find files older than a day.
find /dir1/dir2/ ! -name . -prune -name "s*.txt" -type f -mtime +1 -exec echo {} \; | wc -w
It was working fine for the last few days now it suddenly stopped working. I can clearly see files in the... (5 Replies)
Hi guys, I've found two nifty little scripts on these forums one which detects if the F5 key has been pressed:
#/bin/sh
_key()
{
local kp
ESC=$'\e'
_KEY=
read -d '' -sn1 _KEY
case $_KEY in
"$ESC")
while read -d '' -sn1 -t1 kp
do
_KEY=$_KEY$kp
... (0 Replies)
Hi All,
I would like to develop a shell script for stop & start an application server (1-4) on Solaris box. Here are the user requirements for this task.
1. User will input the option which server they wish to stop.
2. Will clear cache files from specific location.
3. ... (1 Reply)
Script_A.sh has
echo "In am in script A"
ksh ## K-shell is invoked.
Script B.sh ## which I am writing...
./script_A.sh
echo "I am in script B"
return 0
When I run:
$> Script_B.sh
$> I am in script A
$>
Basically, on calling Script_A.sh from within Script_B.sh I have the issue of... (2 Replies)
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)
Hello,
I am ftping the file from one unix box to another box. This script works fine. Only problem here is, it is asking the password when ftp the file. How can i stop that. I am providing the password inside the shell script. But it is not accepting this. I need to put this script in crontab.... (5 Replies)
Hi,
I am writing a bash shell script. How can I tell it to stop. For example, I would like to have something similar to the following:
mike=1
if ; then
STOP THE SCRIPT
fi (3 Replies)
How to stop the Prstat using shell script ?
because after i run the below script the thing seems to be always in loop and cannot get out till i ctrl + c, is there anything that i can add in the script to make it terminate ?
<code>
#!/bin/sh
prstat -Tc -u testing > testing.txt
</code>
... (19 Replies)