LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-22-2011, 02:13 AM   #1
cory94bailly
LQ Newbie
 
Registered: Jul 2008
Posts: 8

Rep: Reputation: 0
Changing user and running commands inside of a script?


My current script is as followed:
Code:
#!/bin/sh
su et
cd "media/ET"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
exec ./ettv.x86 "$@"
That's probably completely wrong, I took the default ET script and tried adding my own additions.

The exact order I need to do things is:
  1. Change users to "et"
  2. CD to "/media/ET"
  3. run ./ettv.x86

I want ET to be run as the user "et" and for some reason, I can't directly su/sudo to run the file without being in the user "et" and the "/media/ET" directory.

This may not be exactly "newbie" but I couldn't find any other forum and I'm hoping someone here can help.

Thanks
 
Old 02-22-2011, 09:19 AM   #2
headrift
Member
 
Registered: Sep 2005
Distribution: Gentoo, Sabayon, Puppy, Arch
Posts: 165

Rep: Reputation: 29
How about:

Code:
su -c 'cd /media/ET/ && LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ettv.x86' - et
 
Old 02-22-2011, 01:57 PM   #3
cory94bailly
LQ Newbie
 
Registered: Jul 2008
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by headrift View Post
How about:

Code:
su -c 'cd /media/ET/ && LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ettv.x86' - et
When I tried that, I got this:
Quote:
cory@Cory-LAPTOP:~$ su -c 'cd /media/ET/ && LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ettv.x86' - et
Password:
No directory, logging in with HOME=/
-su: line 0: cd: /media/ET/: No such file or directory
cory@Cory-LAPTOP:~$
I have to be using the 'et' user in able to see/access the '/media/ET' directory. And I can't run the 'ettv.x86' without being in the directory.

It is a bit inconvenient but I guess I don't mind it :P

Also, is there a way to hardcode the password for 'et' into the script? I'm not worried about security issues at all, it's a laptop and it's for a user with access to only one directory.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
i get an error message running php script inside a cgi script. repolona Linux - Software 0 02-22-2007 10:10 PM
running sed inside script file bajaj111 Linux - Software 9 11-08-2006 10:23 AM
where to place certiain commands inside shell script beeblequix Linux - Newbie 8 08-10-2006 12:12 PM
Running super user commands as normal user mickyg Linux - Security 5 10-14-2005 08:25 PM
changing the user inside a shell script sanjith11 Programming 2 04-22-2004 08:44 AM


All times are GMT -5. The time now is 08:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration