LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-20-2011, 03:04 PM   #1
linux_beginer
LQ Newbie
 
Registered: Mar 2011
Posts: 24

Rep: Reputation: 0
login to user using script


!!!Hello Everyone!!!

I am trying to write a script. The purpose of the script is to login to perticular user and execute some commands.

#/bin/bash
su tom -c "df -h"

When I am running this script as root, it is not asking me any password.
but I want to run this script as normal user. When I am running this script as normal user it is asking me password for user tom.
I want to provide password in script only.

How can I do it? Can I use --stdin?
 
Old 03-20-2011, 04:15 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
I would suggest using sudo, not su. it's much more suited for this, no ned to sneak passwords in or anything.
 
1 members found this post helpful.
  


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
[SOLVED] Script which will login to particular user and execute some commands. linux_beginer Linux - Newbie 6 03-20-2011 01:06 PM
A script for deleting user , if he has no login shell. meandsushil Linux - Newbie 4 11-26-2010 09:51 AM
user login script infekt Linux - Newbie 2 08-26-2007 02:49 PM
User Login script? mkim Linux - Software 2 10-21-2005 05:13 PM
Running a script at user login? brucebearau Debian 1 01-19-2004 04:28 AM


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