Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Expect command to switch user Post 302322797 by Corona688 on Thursday 4th of June 2009 03:06:29 PM
Old 06-04-2009
I might reccomend using the sudo system to run commands as another user instead of keeping a plaintext password in a script file...
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Non-interactive user switch to root

Is is possible switch user from a non-root user to root user without entering the password interactively inside a korn shell script which is run by a non-root user? e.g. I have a non-root user called infodba who is in dba group and I want to create a shell script which is executed by infodba... (5 Replies)
Discussion started by: stevefox
5 Replies

2. Shell Programming and Scripting

Expect help/interaction with switch..

Hi All, I have been trying to get an Expect program to communicate with a Remote Power Switch which will eventually log in, and then turn on/off certain outlets. For some reason, I can't get through the log in procedure with this Switch. When you first spawn the telnet, you get the Switch... (1 Reply)
Discussion started by: mrjgs70
1 Replies

3. Shell Programming and Scripting

Switch to different user without expect

Hi, I have to switch to a different user and execute certain commands and then come back to the original user Ex: My id is 'usstage'. I need to switch to 'apstage', souce a script there, execute a function and then get back again to usstage. Please note that I do not have expect installed... (4 Replies)
Discussion started by: sugan
4 Replies

4. AIX

Switch user(su) two times

Is it possible to switch to root(if allowed) and then with root privileges switch to another user account "ABC"? To further explain the scenario, ABC is an account which has sugroups=su2DEF and root is not part of su2DEF group. but, given that root can switch to any account(correct me if I am... (7 Replies)
Discussion started by: mtwain
7 Replies

5. Shell Programming and Scripting

switch as another user without password

I want to switch as another user without using password .Is it posiible ? I have one server B and I have logged in as username u1 but I want to login to that same server using username as u2 but I don't want to give the password for u2. (3 Replies)
Discussion started by: maitree
3 Replies

6. Shell Programming and Scripting

switch user from local user to root in perl

Hi Gurus, I have a script that requires me to switch from local user to root. Anyone who has an idea on this since when i switch user to root it requires me to input root password. It seems that i need to use expect module here, but i don't know how to create the object for this. ... (1 Reply)
Discussion started by: linuxgeek
1 Replies

7. Shell Programming and Scripting

using expect to switch users in a script

hi, I need to switch users in a script I'm newbee to expect I wrote two files 1 sudo.exp, since su4098 is used as root in my laptop #!/usr/bin/expect spawn su su4098 expect *Password:* send mypsw\n interact 2 test.sh ls ./sudo.exp tcpdump -i wlan0 su esolve ls however, in... (1 Reply)
Discussion started by: esolve
1 Replies

8. Shell Programming and Scripting

Switch user terminal error

Hello All, Here I am trying to login a Linux machine as admin user from a Solaris box.. & then switch to root user.. Code I use: ssh admin@<IP> << END su - root << A echo "Hello I am logged in as root" exit A exit END But the error I get.. su: must be run from a... (3 Replies)
Discussion started by: ailnilanjan
3 Replies

9. Shell Programming and Scripting

How to Switch from Local user to root user from a shell script?

Hi, I need to switch from local user to root user in a shell script. I need to make it automated so that it doesn't prompt for the root password. I heard the su command will do that work but it prompt for the password. and also can someone tell me whether su command spawns a new shell or... (1 Reply)
Discussion started by: Little
1 Replies

10. Shell Programming and Scripting

Expect command to send the user input enter or ctrl+c

Hey All, I am writing one script using expect, that script which is used in spawn will accepts only 1. Enter 2. Ctrl+c Press Control-C to exit, Enter to proceed. Could some one share some thoughts to send the above user inputs in linux expect block ? Thanks, Sam (0 Replies)
Discussion started by: SCHITIMA
0 Replies
SYSMON_PSWITCH(9)					   BSD Kernel Developer's Manual					 SYSMON_PSWITCH(9)

NAME
sysmon_pswitch -- framework for power switches SYNOPSIS
#include <dev/sysmon/sysmonvar.h> int sysmon_pswitch_register(struct sysmon_pswitch *smpsw); void sysmon_pswitch_unregister(struct sysmon_pswitch *smpsw); void sysmon_pswitch_event(struct sysmon_pswitch *smpsw, int event); DESCRIPTION
The machine-independent sysmon_pswitch provides a framework for power management. The interface has been largely superceded by the pmf(9) framework, but sysmon_pswitch is still used to manage power switches as well as related mechanical adapters and buttons. These are encapsu- lated in the following structure: struct sysmon_pswitch { const char *smpsw_name; /* power switch name */ int smpsw_type; /* power switch type */ LIST_ENTRY(sysmon_pswitch) smpsw_list; }; Unsurprisingly, smpsw_name specifies the name of the power switch and smpsw_type defines the type of it. The following types are defined: PSWITCH_TYPE_POWER PSWITCH_TYPE_SLEEP PSWITCH_TYPE_LID PSWITCH_TYPE_RESET PSWITCH_TYPE_ACADAPTER PSWITCH_TYPE_HOTKEY If the type is PSWITCH_TYPE_HOTKEY, there are few predefined names that can be used for smpsw_name: PSWITCH_HK_DISPLAY_CYCLE display-cycle PSWITCH_HK_LOCK_SCREEN lock-screen PSWITCH_HK_BATTERY_INFO battery-info PSWITCH_HK_EJECT_BUTTON eject-button PSWITCH_HK_ZOOM_BUTTON zoom-button PSWITCH_HK_VENDOR_BUTTON vendor-button Once a power switch event has been proceeded, sysmon_pswitch will inform the user space powerd(8), which will possibly execute a script matching the type of the power switch. FUNCTIONS
After the sysmon_pswitch structure has been initialized, a new power switch device can be registered by using sysmon_pswitch_register(). The device can be detached from the framework by sysmon_pswitch_unregister(). The sysmon_pswitch_event() is used to signal a new power switch event. There are two possibilities for the value of event: PSWITCH_EVENT_PRESSED A button has been pressed, the lid has been closed, the AC adapter is off, etc. PSWITCH_EVENT_RELEASED A button has been released, the lid is open, the AC adapter is on, etc. The corresponding events in powerd(8) are pressed and released. SEE ALSO
powerd(8), pmf(9), sysmon_envsys(9), sysmon_taskq(9) AUTHORS
Jason R. Thorpe <thorpej@NetBSD.org> BSD
January 26, 2010 BSD
All times are GMT -4. The time now is 12:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy