Script only runs as a particular user


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script only runs as a particular user
# 1  
Old 07-31-2012
Script only runs as a particular user

Hi guys

So I've got this PERL script that for one reason or another I need to run as a user other than the user that created the script.
When I su - to another user the script won't run and doesn't give me any output as to why. No permission denied or anything like that.
I've chmod 777'd the script but still no joy. What am I missing?
# 2  
Old 07-31-2012
Hi Jay,

If you want the script to run as the same user all the time, you should use the Set User ID bit - so no matter who runs the script it will run as the user that owns it.

As for no output etc, you'll have to check the user environment.

To set the SUID bit.

Code:
chmod 4XXX /path_to_file

Regards

Dave
# 3  
Old 07-31-2012
Thanks for the reply Gull. I don't want it to run as the same user all of the time. In fact I need to make sure that it is NOT run as the user that created it (it's a long story).

Anyway can I use this chmod 4XXX /path_to_file to make the script executable by everyone? What am I replacing the X's with (talking to an utter noob here sorry! :P)
# 4  
Old 07-31-2012
Hi Jay,

To make the script executable by any one use the following;

Code:
chmod 755 /path_to_script

Things to be aware of here are the script may well be suppressing some of the output, although you should get at least a not found or a permission denied message. You'd have to have a look at yhe perl script to determine that.

Users will have to either invoke the script with it's full path name or have their path amended to include the file directory.

Regards

Dave
This User Gave Thanks to gull04 For This Post:
# 5  
Old 08-01-2012
Thanks again Gull but still no joy. Literally all that happens is this:

user1@server> ./script.pl

running...
running...
running...

Ctrl + c

user1@server>su - user2
password:
user2@server> ./script.pl
user2@server>

---------- Post updated at 01:48 PM ---------- Previous update was at 01:35 PM ----------

Ok got it. It's the standard output being redirected like you said. The reason this is happening is because the script makes directories and user1 has permission to create said directories but user2 doesn't. Thanks Gull!
This User Gave Thanks to Jaymoney For This Post:
# 6  
Old 08-01-2012
Thank you for following up with your solution. It may prove helpful to someone else in the future.

Regards,
Alister
This User Gave Thanks to alister For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Script only runs first time through crontab

Hello, I am trying to run a script through crontab and it runs the first time and then it does not run. I tried to run a simple script (as shown below) and I see the same issue. #!/bin/ksh clear echo "Good Morning, World." > /tmp/test123 Crontab Entry: 30 09 * * *... (9 Replies)
Discussion started by: hasn318
9 Replies

2. Shell Programming and Scripting

Script runs manually, but not from cron

Hi, I "borrowed" a script I found online, to start a SAP router application on a Solaris 11 (SPARC) server. The script runs fine when calling it manually, but when I schedule it to run from cron, it doesn't. I don't see any warning or failure messages anywhere, just nothing happens. ... (11 Replies)
Discussion started by: bredman
11 Replies

3. UNIX for Dummies Questions & Answers

[SOLVED] Only half my script runs

Hello out there, I got this script that runs partly fine by my crontab. Problem is it gets to the sleep 300(which should be 5 minutes right?) part and never runs the rest of the scripts past that. All individual scripts run just fine. My var/mail file only shows it up to the " echo "Loader Stop... (3 Replies)
Discussion started by: vsekvsek
3 Replies

4. Shell Programming and Scripting

Need to run a bash script that logs on as a non-root user and runs script as root

So I have a script that runs as a non-root user, lets say the username is 'xymon' . This script needs to log on to a remote system as a non-root user also and call up a bash script that runs another bash script as root. in short: user xymon on system A needs to run a file as root user and have... (2 Replies)
Discussion started by: damang111
2 Replies

5. Shell Programming and Scripting

Shell script which runs sql script

Hi all, I need a shell script which runs a sql script but I couldn't find how to finish it. This is the code that I have: #! /usr/bin/ksh export SHELL=/bin/ksh export ORACLE_SID=database export ORACLE_HOME=/opt/oracle/product/9.2.0.8 sqlplus user <<EOF @/path/path/path/scriptname.sql... (3 Replies)
Discussion started by: Geller
3 Replies

6. Solaris

Sunsolaris shell script runs only as super user

Hi Friends, I am new to Sun solaris unix.I am facing problem while runing my kornshell script just as an ordinary user.The script works fine while i am working as a super user.the script just uses awk to check the first charcter of a file and then copies the file to another folder. Do i... (4 Replies)
Discussion started by: gjithin
4 Replies

7. Shell Programming and Scripting

Shell Script: want to insert values in database when update script runs

Hi , I am new to linux and also also to shell scripting. I have one shell script which unpacks .tgz file and install software on machine. When this script runs I want to insert id,filename,description(which will be in readme file),log(which will be in log file) and name of unpacked folder... (1 Reply)
Discussion started by: ring
1 Replies

8. UNIX for Advanced & Expert Users

My script runs too slow :-(...

Hello experts, I have a series issue in script that result with bad peformence and I wonder if you can assist me. For example I have two files: File-New, size 15Mb. File-Old, size 1Mb. File-New content: a b c k File-Old content: d f a b (0 Replies)
Discussion started by: roybe
0 Replies

9. UNIX for Dummies Questions & Answers

What user runs cron?

I have a command that is found in /usr/ud51/bin called stopudt which safely stops idle database users (let's writes finish, etc). If I login as root and issue stopudt the process is stopped. I put a script in cron to run it and it says stopudt not found. /usr/ud51/bin is in root's PATH. ... (10 Replies)
Discussion started by: michieka
10 Replies
Login or Register to Ask a Question