LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-05-2007, 01:20 PM   #1
chad504
LQ Newbie
 
Registered: Sep 2005
Distribution: FC5, FC6, RHEL 4
Posts: 10

Rep: Reputation: 0
Script Help


I'm trying to write a script to start multiple tomcat instances on a web server. Each app directory is owned by a separate user, for segregation. In order to start each properly, I need to be able to write something to read the owner of the folder, so I can sudo as that user to start/stop it properly. The issue is, I cna't find an easy way to read the owner of the folder, in the script.
 
Old 12-05-2007, 02:09 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
You could always use the stat command to retrieve the info. It should print off the UID/Username and GID/Groupname on the Access line. Just use a little sed/awk/cut magic to pull what you need.

Example output:

[user@localhost home]# stat /home
File: `/home'
Size: 4096 Blocks: 16 IO Block: 4096 directory
Device: 901h/2305d Inode: 7503873 Links: 28
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2007-12-05 20:07:24.000000000 +0000
Modify: 2007-10-26 16:15:10.000000000 +0000
Change: 2007-10-26 16:15:10.000000000 +0000
 
Old 12-05-2007, 02:44 PM   #3
PDock
Member
 
Registered: Aug 2004
Distribution: Slack10 & curr. tried numerous
Posts: 189

Rep: Reputation: 37
Assuming there is no real down side to trying to start tomcat for a user that does not have a directory .AND. you can login as root then:

read the /etc/password file for user id's > distribution minimum ie 1000; then form that list try and su to that user and issue your start command.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
set variables in a bash script; ansi PS1 color script donnied Programming 4 11-21-2007 11:33 AM
Shell Script: want to insert values in database when update script runs ring Programming 2 10-25-2007 10:48 PM
i get an error message running php script inside a cgi script. repolona Linux - Software 0 02-22-2007 09:10 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 04:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:54 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
Open Source Consulting | Domain Registration