su

Android: Screencap to bytes directly - Skip saving to file

送分小仙女□ 提交于 2019-12-09 19:29:53
问题 I use the following code to take screenshot on a rooted device: sh = Runtime.getRuntime().exec("su", null,null); os = sh.getOutputStream(); os.write(("/system/bin/screencap -p " + "/sdcard/img.jpg" + "\n").getBytes("ASCII")); os.flush(); os.close(); sh.waitFor(); myBitmap = BitmapFactory.decodeFile("/sdcard/img.jpg"); As i want to take screenshots frequently, I don't want to first save it to the file and then read the bytes. Is there a better way to get the screenshot bitmap directly? I just

Passing a password to “su” command over sshexec from ant

China☆狼群 提交于 2019-12-08 02:20:19
问题 Is there any way to pass a password to the linux "su" command? I'm attempting to automate a deployment using sshexec and Ant. As part of that I need to execute the "su" command, but I can find no way to give it a password. The su command does not have the -S switch like sudo. I've tried using the commandResource and input properties on sshexec, but I just get an "su: Sorry" back. Before anyone thinks I am, I am not storing passwords in files. The script to execute is being generated in memory

How can I su from root to db2inst1 and invoke a SQL script, in one line?

蹲街弑〆低调 提交于 2019-12-08 01:31:47
问题 How can I su from root to db2inst1 and invoke a SQL script all in 1 line? I am thinking about something like this: su db2inst1 | db2 CONNECT TO myDatabase USER db2inst1 USING mypw; db2 -c -i -w -td@ -f /tmp/deploy/sql/My.sql | exit; Any ideas? 回答1: You can use the -c or --command=<command> option to execute a command with su . In your case, something like this: su -c 'db2 CONNECT TO myDatabase USER db2inst1 USING mypw; db2 -c -i -w -td@ -f /tmp/deploy/sql/My.sql' db2inst1 回答2: if using

Trouble logging in user using su and expect script

北城以北 提交于 2019-12-07 17:25:11
问题 I am working on making a website for a class that you log into with a username and password, and then it takes you to a page that shows your grades in the class. The website is being run with a bash script, and will be hosted on a machine where the users already have a username and password to login. I also have a script called calcgrade.sh that will calculate the grades for either the user who is currently logged in, or the user passed to the script as an argument. So originally, I was going

Mounting afp as different user for php access

懵懂的女人 提交于 2019-12-06 14:27:59
问题 I've mounted an afp directory, afp://ServerName/Foo/, with "Finder->Go->Connect to Server" to /Volumes/Foo, now I'm trying to access it with: opendir("/Volumes/Foo/dirname/"); However, I get an Warning: opendir(/Volumes/Foo/dirname/) [function.opendir]: failed to open dir: Permission denied in... mount in terminal gives me: afp_1VqvPY000e413wKcJE13gANY-7.2d000004 on /Volumes/Foo (afpfs, nodev, nosuid, mounted by daniel) So I need to mount the folder as _www, or somehow allow _www to use my

How can I switch user in a Capistrano task?

怎甘沉沦 提交于 2019-12-06 14:15:53
问题 I made a small test task below: set :user, "user" set :password, "password" set :root_password, "root password" set :use_sudo, false role :srv, "exmaple.com" task :show_info do run "iptables -L", :shell => "su -" do |channel, stream, data| channel.send_data("#{root_password}\n") end end This server doesn't allow me to use sudo , so I have to login as a normal user then become root. I have also tried to create surun from this article, though it doesn't help me... :( Could someone please tell

Running monit as a restricted user and making it watch a process that needs root privileges

旧街凉风 提交于 2019-12-06 10:33:08
问题 I have a specific script written in Ruby that needs root privileges. Most of the other processes don't need that and so were easy to setup in Monit. Not this one. The server needs to listen at 386, and this port is only available for root. I won't get into the details of why, because 1) I'm not a low-level kind of guy, 2) It worked fine so far when using sudo. The monit configuration file is simple and looks like this: set logfile syslog facility LOG_daemon # Default facility is LOG_USER set

Passing a password to “su” command over sshexec from ant

坚强是说给别人听的谎言 提交于 2019-12-06 07:10:55
Is there any way to pass a password to the linux "su" command? I'm attempting to automate a deployment using sshexec and Ant. As part of that I need to execute the "su" command, but I can find no way to give it a password. The su command does not have the -S switch like sudo. I've tried using the commandResource and input properties on sshexec, but I just get an "su: Sorry" back. Before anyone thinks I am, I am not storing passwords in files. The script to execute is being generated in memory in Ant based on prompting for a password. osundblad Not an expert at this but you should probably use

Running an app with root permission in Android

会有一股神秘感。 提交于 2019-12-06 05:54:47
问题 Do you know how to run an app in Android with root permission? I used the following snippet but the root permission is only granted to generated process , not the app itself. process = Runtime.getRuntime().exec("su") 回答1: You can't really, at least not without some kind of horrible hack. You cannot make an existing process root, it must be that way from its creation. Android applications run inside a Dalvik machine in a process that's forked off of a process called Zygote which maps a lot of

Passing su password in shell script

烂漫一生 提交于 2019-12-06 05:04:10
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. 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 your own commands, since adapting it is difficult and error prone. 来源: https://stackoverflow.com/questions