|Pseudo-terminal will not be allocated because stdin is not a terminal ssh bash|
You seem to assume that when you run ssh to connect to a server, the rest
of the commands in the file are passed to the remote shell running in ssh.
They are not; instead they will be processed by the local shell once ssh
terminates and returns control to it.
To run remote commands through ssh there are a couple of things you can do:
Write the commands you want to execute to a file. Copy the file to the
remote server using scp, and execute it with ssh user@remote command
Learn a bit of TCL and use expect
Write the commands in a heredoc, but be careful with variable substitution:
substitution happens in the client, not on the server. For example this
will output your local home directory, not the remote:
ssh remote <<EOF
To make it print the remote home directory
|gnome-terminal font resize (zoom in, zoom out), but adjust terminal height and width contrariwise for getting a "lock in" of window dimensions|
I can’t tell you for sure, but since this is GNOME and moreover GNOME 3,
it’s unlikely that the Terminal has this kind of customization built-in.
But in Linux, you can always improvise. How about the following.
Find a program that can send keys to an X11 window. Maybe xdotool.
Find a program that can control an X11 window’s geometry. Maybe xdotool.
Write a short script that locates the terminal window (probably just the
focused one), sends it Ctrl-Plus / Ctrl-Minus, waits a tiny bit, then sets
its geometry to the one you like (or to whatever it was initially, which
you can also query with xdotool).
Bind this script to a keyboard shortcut of your choice, say Win+Plus /
Win+Minus. No idea how to do this in modern Ubuntu / GNOME 3, but
GNOME 2’s Metacity used to have GConf keys f
|Linux terminal input: reading user input from terminal truncating lines at 4095 character limit|
I do not have a workaround for you, but I can answer question 2.
In linux PIPE_BUF is set to 4096 (in limits.h) If you do a write of more
than 4096 to a pipe it will be truncated.
#define NR_OPEN 1024
#define NGROUPS_MAX 65536 /* supplemental group IDs are available */
#define ARG_MAX 131072 /* # bytes of args + environ for exec() */
#define LINK_MAX 127 /* # links a file may have */
#define MAX_CANON 255 /* size of the canonical input queue */
#define MAX_INPUT 255 /* size of the type-ahead buffer */
#define NAME_MAX 255 /* # chars in a file name */
#define PATH_MAX 4096 /* # chars in a path name including nul */
|echo new line to terminal only when current terminal line is not empty|
Test your variable's value if it's not empty with -n:
[[ -n $VAR ]] && echo "$VAR"
# POSIX or Original sh compatible:
[ -n "$VAR" ] && echo "$VAR"
# With if:
if [[ -n $VAR ]]; then
if [ -n "$VAR" ]; then
It's actually equivalent to [[ $VAR != "" ]] or ! [ "$VAR" = "" ].
Furthermore in Bash you can test it if it's only filled with whitespaces:
shopt -s extglob ## Place this somewhere at the start of the script
[[ $VAR == +([[:space:]]) ]] && echo "$VAR"
if [[ $VAR == +([[:space:]]) ]]; then
Use [[:blank:]] to only match spaces and tabs and not newlines and the
likes if it's more helpful.
If you want to remove empty lines from input file or pipe you can use other
tools like sed:
sed -ne '/^$/!p'
|VBA to Copy Information From a Folder of Files and Compile Information to a Single Workbook|
This is not the full code, but it should help you.
When you work with multiple workbooks keep track of them. For example start
Dim CurrWB As Workbook
Set CurrWB = ActiveWorkbook
Then in the cycle:
Dim WB As Workbook
For Each StrFile In var
Set WB = Workbooks.Open(loc & StrFile)
Inside the cycle you can find the area to copy doing something like:
R1 = 1
Do While WB.Sheets("Sheet name").Cells(R, 2) <> "Starting text"
R1 = R1 + 1
R2 = R1 + 1
Do While WB.Sheets("Sheet name").Cells(R2, 2) <> "Ending text"
R = R + 1
For R = R1 to R2
CurrWB.Sheets("Report").Cells(RReport, 3) = WB.Sheets("Report").Cells(R,
RReport = RReport + 1
|Reply mail structure information: how to retrieve sent and received information|
There's no standard for the structure of a reply email. It's not usually
done using multipart email, it just uses human-readable text, often with
> prefixes to denote quoted text. This allows replies to be interspersed
inline with the quoted material.
The only standard features of replies are a couple of headers:
References: <ID1>, <ID2>, <ID3>, ...
In-Reply-To contains the message ID of the message that was replied to.
References is a growing list of message IDs -- when you reply, you take the
original message's reference list and append the ID of the message being
replied to at the end.
See RFC 5322 for more details about these headers.
|how to get the information of about database events and actor information|
Look at the MODULE, ACTION and CLIENT_INFO columns of V$SESSION.
Then, in the package(s) and/or trigger(s) you suspect are performing the
update, call DBMS_APPLICATION_INFO.SET_MODULE and
DBMS_APPLICATION_INFO.SET_MODULE(trigger_name, 'trigger start');
-- some code...
-- code which updates the employee table
DBMS_APPLICATION_INFO.SET_ACTION('doing something else');
-- more code...
See also the example provided in the usage notes.
|Execv for own terminal|
The path argument to execv is supposed to be the path specification to the
executable file you want to run, not just a directory as returned by
getcwd. From the manpage:
The initial argument for these functions is the pathname of a file which
is to be executed.
In other words, you're looking for something like:
execv ("/bin/echo", command);
The code you currently have is trying to run your current directory,
something that's unlikely to end well, and something you may have noticed
if you checked the return value from execv along with errno: nudge, nudge,
wink, wink :-)
In terms of what to do for other programs, you simply substitute their full
path name for /bin/echo.
You should also be aware that exec is a family of functions, each with
Some allow environme
|Why do frameworks and git hub ask you to use Terminal?|
Being a newbie is ok.
The terminal is the go to because writing programs, tools, and scripts with
a couple lines of bash or python is, well, a couple of lines versus an
entire gui and all the lines of code to go with it.
meteor create hello-stream
That's telling you to run the program called meteor with the supplied
arguments (create hello-stream).
If you haven't installed meteor, do that next. From their website, open
your terminal and type/paste:
curl https://install.meteor.com | sh
That downloads a file from the URL and pipes (|) it to the sh command. The
file it downloads is a shell script that takes care of setup/installation.
Now go back and try the meteor command again.
You might try and find a terminal tutorial. This is the first one I found:
|How to spawn a terminal?|
There are plenty of examples in the documentation.
child = pexpect.spawn('/bin/bash') will spawn a new child, but if you don't
interact with it, you won't see anything, as the input and output are
handled by pexpect. And if you don't have anything else in your script, the
child will be destroyed when your interpreter exits.
Pexpect doesn't open any visible terminal, the child is running entirely in
the background (unless you call child.interact()).
|Applescript Terminal with OSX 10.8|
Many times with keystrokes, the applescript code runs faster than the
computer interface can perform the typing... so you have issues. The
solution is to put short delays between the typing commands to give the
computer interface time to perform the typing. Also your System Events code
should not be inside the "tell application Terminal" block of code.
Try this. You can play with the normalDelay and shortDelay times to make
them longer or shorter as needed.
set normalDelay to 1
set shortDelay to 0.2
tell application "Terminal" to activate
delay normalDelay --give time to activate Terminal
tell application "System Events"
keystroke "cd " & ingestPath --path to autoingestion.class
keystroke "java Autoingestion " &
|How to run my php file from mac terminal|
In order to change the directory, you must type cd and then the file path
If you find the file in Finder, and hold the file, and drag it to the mac
terminal window, it will place the entire path file....so just type cd,
then drag file to get path
DO NOT FORGET TO REMOVE THE FILE NAME ON THE END OF THE PATH
and that will take you to the directory of the file..
after that, just type your "php test.php" (without quotes), and that should
Hope this helps!
|Mac terminal problems|
As the commenters have pointed out, it is recommended that you try to use
rvm or its cousins, to install ruby into your home directory, this way, you
dont need root to install gems by default, and this is more widely
Alternatively you could try the same chown trick here
sudo chown -R <username>:<username> /Library/Ruby/Gems
The second one is usually group name, it can be skipped, or you can let it
|qt printing to terminal|
You can use qDebug() << ..., qWarning() << ..., etc. Don't
forget to include <QDebug>.
|How do I run .scptd from Terminal in Mac?|
You can use osascript to run apple scripts in the terminal.
|Vim UTF8 characters in terminal|
These escape characters appear when Vim is confused about what key presses
it receives from the terminal emulator. The arrow keys are received as
Escape followed by a character from A to D:
^]0A is <up>,
^]0B is <down>,
^]0C is <right>
^]0D is <left>.
Editing an UTF-8 file has nothing to do with your issue.
Here is what I have in my /.vimrc to work around that problem:
nnoremap <Esc>A <up>
nnoremap <Esc>B <down>
nnoremap <Esc>C <right>
nnoremap <Esc>D <left>
inoremap <Esc>A <up>
inoremap <Esc>B <down>
inoremap <Esc>C <right>
inoremap <Esc>D <left>
I'm not aware of a better solution.
|OSX Terminal Tabs/Windows|
I have found the answer due to rubber duck debugging with my friend
@artlogic on Twitter. The problem (or solution, however you choose to see
it) was in System Preferences > General, the option "Close window when
quitting an application" was checked and therefore closing the windows
before quitting the application thus nullifying the effect I hoping for.
That is all.
|Making -std=c++11 the default in mac terminal|
Create an alias: alias g++='g++ -std=c++11' should do the trick.
(However, the version of GCC that comes with OS X is so ancient that it
doesn't support C++11, you'd be better off using clang and clang++.)
|Red color in terminal not working|
There must be something with your terminal settings, since the code you
sent is correct. I get:
and my settings are:
and I use Konsole on KDE4.
|Can Java ant spawn a new terminal|
You can configure the java task to use javaw instead of java, so:
<java jvm="javaw.exe" ...>
I should caveat that I haven't tried this before (and I don't use ant
anymore), but I don't see why this shouldn't work.
|Deleting SSH keys terminal|
Depending on where they are located:
If they are in the default location then you can do
However this is likely answered already elsewhere.
|How to not echo here document to terminal?|
echo "Enter sudo pass:"
read -s SUDOPASS
expect -c 'spawn ssh -tt remote_host sudo cat /etc/cma.conf ; expect -re
"\[sudo\] password for .*:"; send "'"$SUDOPASS"'
|Determining whether STDERR is going to terminal|
I think what you're looking for is isatty(3), in unistd.h. There's no way
to tell whether a file handle has been redirected, period, but that'll tell
you whether it's still interactive. See the source for the tty command in
|stop python in terminal on mac|
CTRL+d -> Defines EOF (End of File).
CTRL+c -> Will terminate most jobs.
If, however you have written a python wrapper program that calls other
python programs in turn, Ctrl-c will only stop the the job that is
currently running. The wrapper program will keep running. Worst case
scenario, you can do this:
Open up: Applications -> Utilities -> Activity Monitor, Find the process
labeled as python, highlight it in the activity monitor then click on "Quit
These three suggestions should work for most situations where you want a
program to stop.
|Connecting to .sql file from terminal on a Mac|
The SQL dump is usually a text file containing SQL commands like CREATE
TABLE ... and INSERT INTO ... which will eventually construct the desired
database for you. In order to execute these commands you will have to
connect to the database server first and then (probobly also) select a
database on that server.
|Git error on GitHub for Mac asking me to use terminal to "git add"|
I understand that you want to use your GitHub for Mac GUI, but if you were
to commit your changes through the terminal instead, here is what you would
# Get the status of your working copy:
$ git status
# On branch Integrating-a-recommendations-textbox
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working
# modified: assets/app/scripts/templates/popups/recommend.hbs
# modified: web/wgwt/models.py
# modified: web/wgwt/views.py
# Add each file you want to commit individually:
$ git add web/wgwt/models.py
# Or add them all at once:
$ git add "*"
# Make your commit
$ git commit
# You can also use the `--all` or `-a` flags during the commit
|How to open emacs gui/ide from mac terminal?|
To do what you want, you'd need to find the location of the actual binary
contained in Emacs.app, and use that as the command instead of emacs. Most
likely, it's at
Which, if you have Emacs.app in your Applications folder, as would be
typical, would be
To set it up with a shorter command to use, you could try adding to your
.profile (I don't know what shell you use) the following line, or whatever
equivalent it has for your shell (This works for bash and zsh, at least):
|Importing a SQL db into mysql using the terminal|
I found an SO post here.
I used "source" like so:
That worked. Great but the internet seemed to want me to use the method
mysql -u username -p password databasename < filename.sql
I may post another question on when to use that second method but in the
meantime I just used source from a SQL dump file
|Parsing terminal arguments Qt Mac OS X|
First of all, you will have to link against the OX-X Framework. OSX works
with Events similar to signal slots. The filename will also be given by an
apple event. I`ve had this quite some time ago with another language, but i
still found a reference:
|Closing a Terminal File|
You appear to be in vim and are in insert mode.
To save and close, you have to get out of insert mode. Hit the 'escape' key
(or control-[, which I personally like since I don't have to pull my
fingers away from the keyboard. I'm not currently at a mac, so I'm not sure
if it's control-[ or command-[ in your terminal).
Now type ':wq', without the quotes. Don't forget the colon. This is a vim
command which will (w)rite and (q)uit.
I believe git has opened this file for you as a temp file, and once you've
finished writing to it, git will use that file automatically for your
commit message. No worries about where to save it.
|Vim colors too bright (terminal)|
You shouldn't compare colorschemes in GUI Vim and in CLI Vim: the number of
colors that can be used in both contexts is very different and it makes any
comparison worthless. You can get very subtle colors in GUI Vim but you can
only approximate them in CLI Vim.
The values used for the gui and those used for the cli are probably
different which explains what you see.
The only way to have the same colors in gui and cli vim is to use only
colors from the xterm palette for the gui.
In Vim, you could :set background=light (and read :help 'background') to
see if it makes the colors less bright.
In your terminal emulator, you could see if there's a setting that deals
with color brightness or the usage of bold.
|Run terminal inside vim on a macbook?|
Why don't you do things the other way around?
You can use a terminal multiplexer such as Tmux and split a terminal window
into two panes using C-b %.
Inside the second pane you can run macvim inside a terminal with $ mvim -v
You can navigate between the two panes with C-b o, (And do much more, but
I'll leave it up to you to discover!)
Doing things this way around is much more sane in my opinion, you get the
full power of both the terminal and vim without having to hack around with
Vim too much (Plus Tmux is very handy for many other uses).
I hope doing things this way around is appealing enough for you!
|Is it Possible using Terminal to run iOS Application in instrument?|
Looks like you're missing a specific device ID ([-w device]). Although the
template might have it, I think you need to specify it anyways at a command
I did a bit of googling around and found this article.
Here's a paired down script based on that article that you could use to run
Instruments from a command line.
if [ ! $# -gt 1 ]; then
echo "You must specify the app location and the test file."
echo " (optionally supply unique device ID of physical iOS device)"
echo " eg. ./build.sh suite.js <xcodeproject directory>/b
|script to record terminal on Mac|
I am trying to compile the package util-linux
(https://github.com/karelzak/util-linux, which contains linux version
script) but without success:
The error message from the compiler on the 'incompatible types' is the clue
to why it failed. There's a conflict between the declarations in the system
header files resident on OS X (BSD-based) and those in the include files
from util-linux(GNU/Linux based).
|How to download j connector using terminal?|
To download MySQL Connector/J:
Log into dev.mysql.com using Oracle SSO
Go to http://dev.mysql.com/downloads/connector/j/
Right-click the blue "Download" button and choose "Copy Link Address" (or
Paste the URL in your Terminal
Depending on what you got available, you could use wget or curl to
download. With curl you would use the -l options with the -o option
specifying a filename:
shell> curl -L -o mysql-connector-java.tar.gz http://...
shell> wget http://...
|I'd like my code to flow with my terminal a little better|
You want to parse the command line arguments instead of reading input after
the program starts.
Use the argparse module for that, or parse sys.argv yourself.
|Grabbing the output from the terminal|
I don't think you can pipe commands like that in subprocess.
Here's a question with answers describing how to execute piped commands
Here's another description of how to do it.
|How do you set the 16 Terminal Colors for Git-Bash?|
Console colors are stored in the registry under HKCU/Console/[window
[window name] is either "Git Bash" for the start menu entry or something
like "C:_Program Files (x86)_Git_git-cheetah_.._bin_sh.exe" for the Windows
Explorer context menu entry (supplied by Git-Cheetah).
Alternatively, the registry settings can be overridden by storing an
NT_CONSOLE_PROPS structure with appropriate ColorTable settings in the "Git
Bash.lnk" shortcut via IShellLinkDataList::AddDataBlock. This happens e.g.
if you edit the properties of a console window started via shortcut, or if
you edit the shortcut properties directly.
If you want the values from the registry instead, create a new "Git
Bash.lnk" shortcut from scratch and leave the Options/Font/Layout/Colors
|png terminal not working gnuplot in OS X 10.8.4|
You have to re-install gnuplot and it's dependent package.
Maybe, you need libpng, libgd.
Installing gnuplot on Mac OS X 10.6
I wanted to install gnuplot, the infamous data visualization tool, on
my laptop running Mac OS X 10.6.6. I got the idea (probably from this
page) that I should build gnuplot from its original sources. Of
course, this brought in a half-mile of dependencies that also needed
to be compiled, mostly via libgd. Thankfully, this libgd and Mac OS X
document from the libgd wiki got me most of the way there.
If you want gnuplot on Mac OS X, you might consider DarwinPorts or
Fink, package systems designed to avoid the kinds of problems I work
through below. I’ve been avoiding packaging systems on my computers,
but not for rational or
|is there a way to combine EOF with a terminal alias?|
Instead, create a function an save it in your ~/.bashrc:
ssh firstname.lastname@example.org << EOF
Source (. ~/.bashrc) and you will be ready to use it with importme.