command

Android Root execute su with parameters

放肆的年华 提交于 2019-12-20 05:38:05
问题 I ve got a problem, executing su with parameters (containing blank space?!). My Command.java looks like this: public class Command { Process process; public String executeCommand(String command) { StringBuffer output = new StringBuffer(); try { process = Runtime.getRuntime().exec(command); process.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line = ""; while ((line = reader.readLine())!= null) { output.append(line + "\n"); } }

How do redirect STDOUT out of XCode compiled Command Line executable?

五迷三道 提交于 2019-12-20 05:36:06
问题 I have a C++ program that writes to stdout that I am trying to compile into a command line utility in XCode. I need the program compiled into a release build (which it seems, XCode calls an Archive - go figure), not run it as debug. I basically want to pipe the output of my program into a textfile like this MyProgram > TextFile.txt I can compile the program into a command line and run it like this via a Bash shell like this: Open MyProgram This spawns a new process (not what I want). However,

Reading complete line in 'for' loop with spaces, tabs with multiple input files

拈花ヽ惹草 提交于 2019-12-20 04:56:17
问题 I have seen articles of 'for' loop. It splits on the occurance of whitespace like space, tab, or newline. To get ride of that issue i have following extra line of command: IFS=$'\n' But when i try to solve the above scenario on following details (i have two files: 'input1.txt' and 'input.txt' on my current directory): BASH command: bash script.sh 'input*' Below is 'for' loop block in script.sh for line in $(cat $1) ... ... done; I got following error on execution: cat: input1.txt input.txt*:

eliminate unwanted output using awk and sed

我怕爱的太早我们不能终老 提交于 2019-12-20 04:54:19
问题 From the following command how can i eliminate all the lines that occur before Owner RepoName CreatedDate EDIT Command: find /opt/site/ -name '.log.txt' | xargs cat | awk '{$NF=""; print $0}' | sed '1i Owner RepoName CreatedDate' | column -t The output is find: Filesystem loop detected; `/nfs/.snapshot/nightly.4' has the same device number and inode as a directory which is 2 levels higher in the filesystem hierarchy. find: Filesystem loop detected; `/nfs/.snapshot/nightly.5' has the same

Executing more than one command with ssh2 exec

断了今生、忘了曾经 提交于 2019-12-20 04:28:04
问题 I have a script that runs one command. Based on that result, I can run the next command. Steps:run first script it puts me in global then from global I will run the next command. First command: $stream = ssh2_exec($connection, 'config global'); After this result I should run this cause I need to go into global $stream = ssh2_exec($connection, 'get hardware cpu'); 回答1: you can do like this $stream = ssh2_exec($connection, 'command1;command2'); 来源: https://stackoverflow.com/questions/13414657

How to send a string to the terminal without having it to be a standard command?

匆匆过客 提交于 2019-12-20 02:33:05
问题 I am writing a program in Java that needs to use terminal command to work. My function basically looks like this : public void sendLoginCommand() throws IOException { System.out.println("\n------------Sending Login Command------------\n"); String cmd="qskdjqhsdqsd"; Runtime rt = Runtime.getRuntime(); Process p=rt.exec(cmd); } public Process sendPassword(String password) throws IOException { System.out.println("\n------------Sending Password------------\n"); String cmd=password; Runtime rt =

executing ADS related Powershell command through Java does not work giving 2 different errors when using 2 different ways

送分小仙女□ 提交于 2019-12-19 11:53:23
问题 I have been trying to execute a set of commands in a powershell session through java, with no luck yet. My aim is to search a computer object in AD with the domain = "domain.com". I started with a single command. Unfortunately, the following command successfully runs in my powershell prompt: Get-ADComputer -Filter { Name -like "hostname" } –Server a.b.c.d:3268 -SearchBase 'DC=domain,DC=com' | FT DNSHostName # hostname is actual hostname provided by user and accepted in argument of Java

Executing external program in java and passing commands

孤街浪徒 提交于 2019-12-19 11:15:33
问题 I have this chess engine Rybka.exe, that i have to execute in java Here is an example how you run Rybka: Once you clicked on it, console opens and waits for input. So then you enter "uci" and you press enter and you wait for it to load (approx. 1 sec) and then you have to enter a few more lines as options and stuff. The problem is that I don't know how to pass those commands from java to Rybka. The fact is that those commands need to be entered one at a time, because you have to wait for some

Redirect outputs of multiple commands to a file

旧城冷巷雨未停 提交于 2019-12-19 10:57:19
问题 I'm running multiple commands in my Linux shell at the same time, e.g. echo "Line of text 1" && echo "Line of text 2" && complexthing | xargs printf "complexspecifier" I want to redirect all output to file1 . I know I can add >file1 after each individual command but this seems bulky. How can I do this? 回答1: exec >file1 # redirect all output to file1 echo "Line of text1" echo "Line of text2" exec > /dev/tty # direct output back to the terminal Or, if you are on a machine that doesn't have /dev

ADB shell script to send AT commands to a modem-cannot return control to a shell and capture output

故事扮演 提交于 2019-12-19 10:49:17
问题 I already posted similar question, but still could not get my job done, so this a a second attempt, where I would like to more clearly state my stumbling block. So basically I am in Android phone's adb shell, communicating with the GPRS modem by sending AT commands. I am able to do it by redirecting at command to the device file representing the modem; and I can read back the response using cat utility running on the background (started earlier). I implemented it in a script which can send a