su and run script problem


 
Thread Tools Search this Thread
Operating Systems Solaris su and run script problem
# 1  
Old 08-15-2011
su and run script problem

Hi, it's there a way to for me to su to run script?
It seems like if i put

Code:
su - <user1>
cd <path>
touch <file1>

It will stop at su without running the cd & touch command.
# 2  
Old 08-15-2011
Code:
su - user1 -c "touch path/file1"

# 3  
Old 08-15-2011
I tried that, however it is not running the program. (No files are created)

Code:
su - <user1> -c /path/touch.sh

---------- Post updated at 04:04 PM ---------- Previous update was at 03:51 PM ----------

Hi, it works actually, i just have to put the full path inside my touch.sh.

If i need to run a shutdown script also that need to put in user name & password in the script, how do i do that?

Inside my touch.sh
Code:
touch <path>/log.txt      -> working
echo `date` > <path>/log.txt     -> working
<path>/adstrtal.sh <user> <password> -> not working

Code:
# touch.sh
You are running adstrtal.sh version 115.19

Enter the APPS username:

I need it to run without human intervention. Thanks.Smilie

---------- Post updated at 04:29 PM ---------- Previous update was at 04:04 PM ----------

I figure that out, for future reference:

Code:
touch <path>/log.txt      
echo `date` > <path>/log.txt     
<path>/run.sh

run.sh (chmod)
Code:
<path>/adstpall.sh <user> <pass>

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

Script fails to run properly when run from CRONTAB

Hello all, I'm trying to write a script to gather and send data and it works just fine at the bash command line, but when executing from CRON, it does not run properly. My scripting skills are pretty limited and there's probably a better way, but as I said it works at the command line, but... (12 Replies)
Discussion started by: rusman
12 Replies

3. Shell Programming and Scripting

Problem run script inside a gnome-terminal

hi, I would like to ask about using gnome-terminal command, I had a script that will run my VBOX VM in headless and i want to display the output(STDOUT) on the gnome-terminal window. The purpose that i want to display the STDOUT of the script cause i will used it or create a desktop shortcut for... (11 Replies)
Discussion started by: jao_madn
11 Replies

4. Shell Programming and Scripting

how to run an already made script run against a list of ip addresses solaris 8 question

how to run an already developed script run against a list of ip addresses solaris 8 question. the script goes away and check traffic information, for example check_GE-VLANStats-P3 1.1.1.1 and returns the results ok. how do I run this against an ip list? i.e a list of 30 ip addresses (26 Replies)
Discussion started by: llcooljatt
26 Replies

5. Solaris

Problem on rsh to run script

Hi, i want to run a touch_file_script.sh on host2 by rsh -ing from host1 to host 2 <host1># rsh <host2> <path>/touch_file_script.sh No error was prompt. However it did not create the file as in the script. # rsh <host2> # sh -x <path>/touch_file_script.sh + touch <file> Run it... (1 Reply)
Discussion started by: beginningDBA
1 Replies

6. AIX

My script didn't run every run every minute at cronjob

In my cronjob, I would like to schedule my script.sh to run every minutes. I crontab -e and have in line below but it didn't seems to run at all. * * * * * script.sh When I run it manually, I can run it. Is that anything wrong with the above line? If I change it to something like below,... (4 Replies)
Discussion started by: ngaisteve1
4 Replies

7. Shell Programming and Scripting

Need to run the script in background, but having a problem

hi, we have a script which runs for the whole day and whenever the job fails, will send an alert to the mailbox. My problem here is that i need to give the jobname dynamically which is not possible if we run the script in background. Pls help me with this. Thanks Ajay (6 Replies)
Discussion started by: ajayakunuri
6 Replies

8. UNIX for Dummies Questions & Answers

problem to run sql startment in script

Hello, I have a script to run a list of customer information, but it not work. can anyone help below: echo "Please input list to check customer detail:" read list for file in 'cat $list.txt' do echo "select cuname as "FROM CUNAME", invo_num as "RECS", total_amount as "AMOUNT", tax_amount as... (7 Replies)
Discussion started by: happyv
7 Replies

9. UNIX for Dummies Questions & Answers

problem when the script is scheduled to run as cron job

Hello, I have problem in executing a shell script. When the shell script is executed at the shell prompt the script works successfully but when the same script is run as a cron job it fails to execute the files called within the shell script. I have scheduled the job in my crontab file as ... (6 Replies)
Discussion started by: forumthreads
6 Replies
Login or Register to Ask a Question