su

How to pass the password to su/sudo/ssh without overriding the TTY?

為{幸葍}努か 提交于 2019-12-16 20:19:12
问题 I'm writing a C Shell program that will be doing su or sudo or ssh . They all want their passwords in console input (the TTY) rather than stdin or the command line. Does anybody know a solution? Setting up password-less sudo is not an option. expect could be an option, but it's not present on my stripped-down system. 回答1: For sudo there is a -S option for accepting the password from standard input. Here is the man entry: -S The -S (stdin) option causes sudo to read the password from the

How to run long Python script without re-prompt for credentials

北战南征 提交于 2019-12-14 02:32:34
问题 I have a Python script, let's say install.py (which I am running as sudo), on OS X that installs homebrew, Xcode, pip, ruby, swig, and, ultimately, salt. The problem is that running and installing everything (Xcode CLI in partituclar) takes so long to run, that sudo times out, requiring another prompt for admin credentials. Here's the thing. As part of install.py , before kicking off all the installations, I first create a local admin user by opening a subprocess and use: make_admin_account =

How to get STDERR in Perl from a command executed in pipe with su -c

六月ゝ 毕业季﹏ 提交于 2019-12-14 02:24:54
问题 I'm trying to capture the output of the command executed as a different user using: my $command = qq(sudo su - <username> -c '/usr/bin/whatever'); my $pid = open $cmdOutput, "-|", $command; How can I capture the STDERR of /usr/bin/whatever ? I tried $pid = open $cmdOutput, "-|", $command || die " something went wrong: $!"; but it looks like this is capturing the possible errors of "open" itself. I also tried my $command = qq(sudo su - <username> -c '/usr/bin/whatever' 2>/tmp/error.message);

Passing su password in shell script

落爺英雄遲暮 提交于 2019-12-13 12:34:55
问题 How can password be passed in a shell script using su(without sudo and except)?. I have tried echo "password" | su root -c .But it didnt work. 回答1: The best way of doing this is with sudo , but since you don't want the best solution, you can you can use script instead: { sleep 3; echo "yourpassword"; } | script -q -c 'su -c whoami' /dev/null This will print root , the output of whoami . Please make sure to try this command verbatim (with password replaced) before trying to adapt it to run

Need to use sudo su - in Unix shell script

可紊 提交于 2019-12-13 03:56:44
问题 I am at beginner level and I need to use sudo su - and pwd in one command line in script for two different users. (I'm using pwd as an example; the specific command is not important.) And I am using command sudo su - user -c pwd . This command works when switching to one user, but not when switching to another. For example:- $ sudo su - ora -c pwd /oracle/ $ sudo su - adm -c pwd Sorry, user myuser is not allowed to execute '/usr/bin/su - adm -c pwd' as root on server. $ How can I make it work

Android- performing su commands programatically does not work

℡╲_俬逩灬. 提交于 2019-12-12 08:07:07
问题 I need my app to perform some su commands programatically (phone is rooted). When done using adb, the commands work. For instance: su -c "mkdir /sdcard/testdir" creates a directory called "testdir" in /sdcard. When I call: p = Runtime.getRuntime().exec("su -c \"mkdir /sdcard/testdir\""); p.waitFor(); It just moves on and no change happens. I tried reading the input: DataInputStream dis = new DataInputStream(p.getInputStream()); while((temp = dis.readLine())!=null) Log.d(ctx.TAG,"shell:"+temp)

Install apk using root? [closed]

Deadly 提交于 2019-12-12 01:43:27
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Is there a way of installing an apk from downloads folder without user input on a rooted device? 回答1: You can simply use adb install command to install/update APK silently. Sample code is below public static void InstallAPK(String filename){ File file = new File(filename); if(file.exists()){ try { String command

Changing unix user in a shell script

空扰寡人 提交于 2019-12-12 01:08:51
问题 I want to change the current user in a shell script in order to give the user the ability to execute the commands as an administrator, by passing the login and password as arguments. I want to have the ability to do something like : sh ./script.sh login password And inside the script, something like : sudo $1 $2 etc... However I can't figure out how to clearly code this. Thanks for any help 回答1: Just Use Sudo The sudoers(5) file allows for very complex permissions and command specifications.

How to run subprograms with root permissions on iOS?

拟墨画扇 提交于 2019-12-10 12:27:48
问题 With the Android SDK, I can run a process as a superuser by invoking su and then running my code. How can I do the same on iOS? Here's what I use on Android: // Elevate to root Process localProcess = Runtime.getRuntime().exec( "su"); // Now run some command as root DataOutputStream localDataOutputStream = new DataOutputStream( localProcess.getOutputStream()); localDataOutputStream.writeBytes( "chmod 666 file.name\n"); localDataOutputStream.writeBytes( "exit\n"); localDataOutputStream.flush();

GDB problems inside docker

走远了吗. 提交于 2019-12-10 10:14:34
问题 With docker version Docker version 1.1.0, build 79812e3 on Ubuntu 13.04, and using the docker container created by: # docker build -t gdb_problem_testing - < THIS_FILE FROM ubuntu RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get install -y build-essential gdb Doing this: user@host $ sudo docker run --rm -it --user=root gdb_problem_testing su root -c bash root@690396061e81:/# cat <<EOF > test.c && gcc -ggdb test.c -o