Operating System - HP-UX
1825789 Members
2093 Online
109687 Solutions
New Discussion

Using another user to run a script yields error

 
SOLVED
Go to solution
Yeo Khian Wei
Occasional Advisor

Using another user to run a script yields error

Hi
I had created this script owned by root that will execute a script owned by another user. if I execute the script on the command prompt, everyting goes through. But if I use nohup to execute the script at the backend. It returns the error -
Cannot start job control
stty: : I/O error.
My script (owned by root) is as follows -
su - testusr1 -c "/home/testusr1/test_print.sh"
Can someone please advise me? Thanks!
5 REPLIES 5
RAC_1
Honored Contributor

Re: Using another user to run a script yields error

Do you have any interactive steps in user's script? Also make sure that all required variables are put in user's script. One way to do it is putting env at the start os the user's script.

You can run script as sh -vx ./script and check where it is failing.
There is no substitute to HARDWORK
Michael Schulte zur Sur
Honored Contributor

Re: Using another user to run a script yields error

Hi,

would it be a big deal to post the script as attachment?
Is the script trying to change attributes of the tty?

Michael
Yeo Khian Wei
Occasional Advisor

Re: Using another user to run a script yields error

Hi
I had executed the script using the sh -vx command. I do not see any errors coming out from that. The only error that I see is when I used the nohup. My script is very simple, since it's for testing purpose, it is doing a single print statement thats all.

Regards,
Khian Wei
Rory R Hammond
Trusted Contributor
Solution

Re: Using another user to run a script yields error

The su - is reading the testusr1 .profile and is causing your problem the stty setting is trying to talt to a terminal

If you are not worried about the environment
su testusr1 -c "/home/testusr1/test_print.sh" should work.
If you need the user env. set the need ones in the test_print.sh.

Rory
There are a 100 ways to do things and 97 of them are right
Dave La Mar
Honored Contributor

Re: Using another user to run a script yields error

I had run into same and found what Rory mentioned as part of the problem. The rest was taken care of when I placed the required environment variables in the script being executed.

Best of luck.

Regards,

dl
"I'm not dumb. I just have a command of thoroughly useless information."