APT-OFFLINE is there a way to bypass the initial menu? - offline

I'm trying to automate system updates on some offline Ubuntu systems with a bash script using the APT-OFFLINE tool. When running (for example) apt-offline install bundle.zip it first presents the user with an option menu:
(Y) Yes. Proceed with Installation
(N) No, Abort.
(C) Display changelog
(?) Display this help message.
What would you like to do next: (y, N, ?)
Looking at the apt-offline man page, I do not see a "-y" option or something similar to bypass this menu. If I'm just executing the initial apt-offline install bundle.zip command in a bash script, how do I have the script automatically enter "y" at the menu prompt and proceed?

Never mind. Had a brain drain. It's a simple answer.
yes | apt-offline install bundle.zip

Related

C++ Windows - fill password field of system("run as")

I know there are many other ways to do this but I want to know how to fill in the password question of the windows the run as command automatically.
system("runas /user:\"benedikt\" \"xy.exe\"");
is there any way to do this? I googled a long time but i only found a lot of tools doing wat I want to do and not a way to do this for myself.
PS: I do not want to use any .Net functions.
OK, I'm going out on a limb here, because I'm not 100% sure that there isn't some (convoluted) way to achieve what you are looking for using stock runas. However, Why doesn't the RunAs program accept a password on the command line?, suggests there isn't - deliberately so to prevent "security issues" with plain-text passwords in command lines, batch files and tools that can view a command line (like Process Explorer).
BTW, a simple echo <password> | runas /user:<user> <command> doesn't seem to work either (it skips over the prompt for the password, but the password itself is not read by runas it seems).
So I guess you have to resort to some other means, like using the real API behind it all: CreateProcessWithLogin.

Print result of Fabric command

I would like to redirect the output of the Fabric command
print local("git add .")
so that I make sure that everything is working properly. Is there a way to pipe the results of this command to the console? Thanks!
You should already see the output of the command in the console since that's the default behaviour. If you need to customize it, please have a look at the managing output documentation section.
Besides this, there's an ongoing effort to use the logging module (issue #57) that should provide more options like logging to a file, but that hasn't been merged into the trunk branch yet.

unable to open .bat files for pan and carte for kettle 4.0.1 stable community version

Hhi all,
I'm using kettle4.0.1 communty version, here iam comfortable with spoon, but for running jobs and all i need to use pan and carte, my problem is other than spoon.bat niether of pan.bat nor carte.bat is opening. iam unable to run kitchen.bat also.. can someone suggest me with best solution
First of all, in order to run jobs you will need to use kitchen.bat (unless you want to execute them remotely). Kitchen, Pan and Carte are command line tools, therefore you will need to specify your parameters also on the command line.
For example, you want to run a file called job.kjb located in C:/jobs/ with a minimal log level. You would execute kitchen.bat from the commandline as follows
kitchen.bat -file=C:/jobs/job.kjb -level=minimal
Please see also more information here:
http://wiki.pentaho.com/display/EAI/Kitchen+User+Documentation

Simple interactive prompt in C++

I work on an application that usually runs unattended. Now I need to add to it something like an interactive prompt. In the interactive mode the operator will be able to give simple commands to the application - nothing fancy, simple commands like start and stop. Parametrized commands (e.g. repeat 10) and commands history could be nice too.
Do you know, by chance, any library that helps with such tasks. I've been thinking about something that works like boost::program_options or gflags but for an interactive prompt and not for command line parameters. Any ideas?
Thanks
Readline is one the best known libraries for this
http://tiswww.case.edu/php/chet/readline/rltop.html
It is covered by GPL, so it is only possible to use in GPL-compatible programs.
I did a quick search for alternatives, and found this:
http://github.com/antirez/linenoise
I'm not sure if the following is a reasonable amount of work for what you're trying to do, but Python has a very nice Command Line Interface (CLI) building library called cmd2. If it's possible to expose the relevant parts of your apps to Python using SWIG or CTypes, then doing the rest should be easy.
Here's a nice video presentation about cmd2:
PyCon 2010:Easy command-line applications with cmd and cmd2
HTH
One possibilty is to open a TCP port and accept messages in text format. Then you can telnet to that port and issue simple commands.

How to highlight and color gdb output during interactive debugging?

Please don't reply I should use ddd, nemiver, emacs, vim, or any other front-end, I just prefer gdb as it is, but would like to see its output with some terminal colors.
.gdbinit
You can tweak your ~/.gdbinit to have colors. You can use mammon's .gdbinit which is available here:
https://github.com/gdbinit/gdbinit
You can tweak it as much as you want too. I found this thanks to this SO answer. Here's the kind of output that you can obtain:
A GitHub repository is also available: https://github.com/gdbinit/Gdbinit
On a side note, the same idea was also applied to lldb.
GDB Dashboard
Following the same concept, GDB Dashboard provides a modular visual interface for GDB in Python.
(void)walker
Another similar project uses GDB's Python support to provide more extensibility, so this is worth checking out: https://github.com/dholm/voidwalker
#dholm also provides his own .gdbinit inspired from the previous one.
pwndbg
Some projects provide a set of useful functions, including improved display. This is the case for PEDA or pwndbg. The latter gives the following description:
A PEDA replacement. In the spirit of our good friend windbg, pwndbg is pronounced pwnd-bag.
Speed
Resiliency
Clean code
It provides commands to support debugging and exploit development similar to the ones from PEDA, and better display (although this is not the main focus of the project). The software is still under development, and has not been properly released yet.
voltron
The project description states:
Voltron is an extensible debugger UI for hackers. It allows you to
attach utility views running in other terminals to your debugger (LLDB
or GDB), displaying helpful information such as disassembly, stack
contents, register values, etc, while still giving you the same
debugger CLI you're used to.
You can modify your .gdbinit to automatically integrate it. However, the display itself is outside of GDB (e.g. in a tmux split).
GEF
GEF is another option, and it is described as:
It is aimed to be used mostly by exploiters and reverse-engineers, to
provide additional features to GDB using the Python API to assist
during the process of dynamic analysis and exploit development.
It's not colours, but consider gdb's text gui. It makes a vast difference to how usable gdb is.
You can launch it with:
gdb -tui executable.out
Screenshot:
As you can see, the main features are:
shows what line of the source we are on and surrounding lines
shows breakpoints
I know you did not want a frontend.
But how about cgdb it is very close to gdb,
it is textmode but has a source window above with syntax highlight on the code.
New in upcoming GDB 8.3!
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/NEWS
Terminal styling is now available for the CLI and the TUI. GNU Source
Highlight can additionally be used to provide styling of source code
snippets. See the "set style" commands, below, for more information.
It is possible to greatly enhance the appears of gdb through the use of colors. This is done via any of the following methods:
Colorized prompt via the "set prompt". E.g., make the prompt bold and red:
set prompt \033[1;31m(gdb) \033[m
or make the prompt a new shape, bold and red:
set prompt \033[01;31m\n\n#####################################> \033[0m
Colorized commands via hooks
Colorized syntax highlighting of the "list" command.
All examples are available at the following blog posts written by Michael Kelleher:
"Beautify GDB", May 12, 2010 (via archive.org)
"Experimental GDB syntax highlighting", May 15, 2010 (via archive.org)
cgdb is much better than gdb -tui
#into .gdbinit
shell mkfifo /tmp/colorPipe
define hook-disassemble
echo \n
shell cat /tmp/colorPipe | c++filt | highlight --syntax=asm -s darkness -Oxterm256 &
set logging redirect on
set logging on /tmp/colorPipe
end
define hookpost-disassemble
hookpost-list
end
define hook-list
echo \n
shell cat /tmp/colorPipe | c++filt | highlight --syntax=cpp -s darkness -Oxterm256 &
set logging redirect on
set logging on /tmp/colorPipe
end
define hookpost-list
set logging off
set logging redirect off
shell sleep 0.1s
end
define hook-quit
shell rm /tmp/colorPipe
end
define re
hookpost-disassemble
echo \033[0m
end
document re
Restore colorscheme
end
Warning: Buggy. No TUI support, 'user-mode' hack.
Found the main part here
and modified it a bit. Needs highlight, c++filt. If colors get messed up issue re command.
Neat, I just found this hack using colout: https://github.com/nojhan/colout/blob/master/colout/example.gdbinit
I wanted to highlight as follows: emphasise the lines of a stack trace which belong to my source files (rather than libraries).
The solution was to use gdb-python (on MSYS; on Linux typically gdb comes with Python built-in already?), hook backtrace, use
python stack_trace = gdb.execute('backtrace', False, True')
Then process stack_trace with Python's regexes, and print them out. Bold and other colours are achieved by a function like this:
def term_style(*v):
"""1 is bold, 30--37 are the 8 colours, but specifying bold may also
change the colour. 40--47 are background colours."""
return '\x1B['+';'.join(map(str, v))+'m'
#Use like this:
print term_style(1) + 'This will be bold' + term_style(0) #Reset.
print term_style(1,30) + 'This will be bold and coloured' + term_style(0)
print term_style(1,30,40) + 'Plus coloured background' + term_style(0)
Another good combination of colors is given by this configuration. It renders inspecting the backtraces a lot easier. To use it, just save that file as ~/.gdbinit and run gdb normally
you can get whatever colors you want;
# gdb
(gdb) shell echo -en '\E[47;34m'"\033[1m"
...
anything is now blue foreground and white background
...
(gdb) shell tput sgr0
... back to normal