How to run an external command from lldb prompt - lldb

Does lldb have an equivalent for gdb's shell command to run external commands from the prompt? (see How can I execute external commands from the gdb command prompt?)

This might be what you're looking for...
(lldb) help platform shell
Run a shell command on a the selected platform. This command takes 'raw'
input (no need to quote stuff).
Syntax: platform shell <shell-command>
Command Options Usage:
platform shell [-t <value>]
-t <value> ( --timeout <value> )
Seconds to wait for the remote host to finish running the command.
IMPORTANT NOTE: Because this command takes 'raw' input, if you use any
command options you must use ' -- ' between the end of the command options
and the beginning of the raw input.

(lldb) platform shell ls
If you get:
error: unable to run a remote command without a platform
Try this command to see if you need to give lldb more context:
(lldb) platform status
If you are debugging on a real iOS ARM device, this will show Platform: remote-ios. If you are on a simulator, you will get your macOS related info.

Related

log in adb shell "interactive mode" and "non-interactive mode"

I'm writing script to run iperf on linux device accessible via adb.
From a terminal, when I run the command: adb shell iperf -c ......
I get the log of the command 50 s after the command starting.
inconvenient: during 50 s you are not sure that iperf has started
I tried the logcat command (logcat --pid ...), It gives the same result.
From a terminal, when I enter adb session first and then I run the command: iperf -c .....
I get the log of the command in real time.
inconvenient: I'm not able to automate the procedure, because I have to start the adb session first
For the first use case: Is there a way to force "log flush" in order to get the log in real time?
For the second use case: Is there a way to send commands to already opened adb shell session?
Is there any other ways to launch iperf on device and get the log in real time?
The solution i found is the library pexpect that allow to interact with adb session.

How to run C program in Netbeans

I am trying to run the dmtx project from Git (link: https://github.com/dmtx/dmtx-utils) in Netbeans. I have configured the Project Properties in NetBeans and the project is building correctly.
When I run a particular C file (dmtxwrite.c) through bash it gives the correct output. As mentioned in the README, the correct way to run it in Bash is:
$ echo -n 123456 | dmtxwrite > image.png.
Now my question is how can I do the same using NetBeans?
Till now I only found answers related to passing command line arguments. However, that does not work.
how can I do the same using NetBeans?
Select your C project in the Projects panel.
Right-click it to open the context menu, then select Properties > Run > Run Command.
Enter your command to be run in the Run Command field.
This is the Help for Run Command in NetBeans 8.2:
Enter a command to be executed when you run the project. The IDE runs the command as /bin/sh -c "run-command" which enables you to use any shell syntax including redirection and pipes. Type the command in the Run Command field the same way you would run it from the command line. For example, you could type my-script -opt1 -opt2 to run a script and specify two options, or mycommand > output.log to run your command and send the output to a logfile. The Run Command list maintains history of previous entries so you can go back to the default value or select among several different commands you have entered.

using adb in command prompt, but receiving error

C:\Users\purpl\AppData\Local\Android\Sdk\platform-tools>ADB SHELL RM /DATA/SYSTEM/PASSWORD.KEY
adb: usage: unknown command SHELL
This line should run android sdk, but it doesn't and comes up with this
Unlike Windows file system adb commands are case-sensitive even on Windows.

posix_openpt() - error - Cant access tty, job control turned off

I'm using a psuedo terminal, /bin/sh -i, by calling normal commands for posix_openpty() then fork(), in language C.
When I run from command line GUI terminal like this
$ ./MyTerminal
or
$ sudo ./MyTerminal
or as root like this
# ./MyTerminal
all works very good and as expected, no problems.
However, when I make a systemd service file like this, it works fine
[Service]
User=root
But when I try to get systemd to run it as normal user like this
[Service]
User=debian
THe first output for /bin/sh -i is
/bin/sh: 0: can't access tty; job control turned off $
And the terminal does not really work.
When I run /bin/bash, fork() w/posix_openpty() is returns me this, but the terminal generally works ok
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
Is such a weird prolem because when running outside of systemd everything works perfect. I see this problem in 1 other question but no clear solution. So what I have to change to make systemd run my file perfectly? Thanks for your help.

windows, Putty, pscp combined in to a single batch file, is it possible?

I'm having trouble getting an answer to my question, in laymens terms. It is probably my lack of knowledge on the subject so, I'm dumbing down the question. I have a windows machine that I run the putty tool from and connect to a linux box. I run " killall /bob/bin/myfile.out " then close putty then type in a cmd prompt pscp.exe myfilet.out.2.3.4 root#192.168.1.1:/bob/bin/myfile.out . Can someone show me how to combine these into a single windows batch file? thank you
You could use the free command line tool Plink to run commands on external servers via SSH.
#echo off
Plink root#192.168.1.1 "killall /bob/bin/myfile.out"
pscp.exe myfilet.out.2.3.4 root#192.168.1.1:/bob/bin/myfile.out || echo an error occurred when copying the file.
the command after || on the second line will only run if an error level is set by the previous command.
I can't add comments yet, but can you elaborate on how you login with putty, but not do the exact same thing with plink? Plink not only accepts all the same options as putty, but if you have a saved session in putty, you can access it from plink. Without any subcommands, plink should essentially make you CMD shell look like a crude putty window, with subcommands, it will execute them and return:
C:\Users\riglerjo>plink savedputtysession
Using username "rigler".
# hostname
s9-chicago.accountservergroup.com
-bash-3.2$ exit
logout
Run the remote command as an option on plink:
C:\Users\riglerjo>plink savedputtysession hostname
s9-chicago.accountservergroup.com

Resources