LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 10-21-2008, 09:48 AM   #16
xmdms
Member
 
Registered: Oct 2003
Posts: 134

Original Poster
Rep: Reputation: 15
Unhappy


Gentlemen,

I hate to open this old subject again, but I ma stuck here. I am still working on the same script, well, I have been busy with some other stask that I haven't had time to work on this until now.

Anyways, when I run this in a script, I think it was asking for a password for su a_agent. Again, I think this is happening when I execute the shell script manualy. If I step through this line per line, the su a_agent doesn't ask for a password.

What can I do at this point? Please advice.

Thanks,
J
 
Old 10-21-2008, 10:05 PM   #17
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Forget that su a_agent stuff.

Just put all your cmds in a shell script (with fullpaths, not ./) and then call the script as described in post #9

Post the full thing ie /etc/rc.local and the shell script if that doesn't work.
 
Old 10-21-2008, 10:35 PM   #18
xmdms
Member
 
Registered: Oct 2003
Posts: 134

Original Poster
Rep: Reputation: 15
Hi Chrism01,

I had it on the /etc/rc.d/rc.local in the beginning and that didn't work. Therefore, I created (with your help) a script and stuck that in /etc/rc.d/init.d and it worked but stuck at the password for soem reason.

I read over your posting #9 and still puzzle me a bit. Could you please provide more details on the commands.

Again, I can't say thank you enough for your time.

J
 
Old 10-22-2008, 01:56 AM   #19
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Ok I'll break it down:
Quote:
su - -c "/home/chris/t.sh" chris
insert that line into /etc/rc.local. That file is run as the last thing at startup by the system as root.
As root, you do not need another user's passwd to run another user's prog, assuming it has executable perms.

su - <-- means switch user
-c <-- means run the following string as a cmd
"/home/chris/t.sh" <-- cmd to run: use absolute path : string must be enclosed in quotes
chris <-- run as this user

Further: all the cmds in your script (t.sh here) must have absolute paths as well, inc paths to files read/written if any. All cmds/progs called must have exe perms.

The only reason you might need a passwd is if (one or more of) the progs you call require a passwd, in which case you'll have to (unfortunately) hard code them in and make your top-level script an 'expect' script:
http://linux.die.net/man/1/expect

Please add your distro to your profile. I'm assuming your distro uses /etc/rc.local. Some (eg RH) do, some don't, in which case they use a different but equiv file/method.
 
Old 10-22-2008, 08:16 AM   #20
xmdms
Member
 
Registered: Oct 2003
Posts: 134

Original Poster
Rep: Reputation: 15
I am currently using RHAS 4.0 (RedHat) ditribution.

Thank you so much!!
 
  


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
shell script to automate TELNET daggulasreedhar Programming 5 08-02-2007 01:13 PM
How to program shell script to automate mass user account creation? EsAsher Linux - General 2 06-30-2007 09:41 AM
Automate FTP session using Shell Script kalyanofb Programming 2 04-07-2007 09:44 AM
startup script when reboot ust Linux - Software 5 09-10-2005 07:19 PM


All times are GMT -5. The time now is 12:51 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