Menu
  • HOME
  • TAGS

hGetLine from /dev/pty/N?

haskell,terminal,filehandle,pty

Don't you want to read from the master handle? ... hMaster <- fdToHandle master hGetContents hMaster >>= print . take 10 ... ...

Running a jar file from terminal in ubuntu

java,ubuntu,jar,terminal

Perhaps your jarfile is corrupted in some way, possibly due to how it was downloaded or installed. this issue is caused by manifest file because you haven't added space after every colon in here, it should be: Manifest-Version: 1.0 Created-By: 1.7.0_79 (Oracle Corporation) Class-Path: mysql-connector-java-5.1.28.jar Main-Class: JavaApplication1 after Main-Class there...

virtualenv does not get activated in new bash shell

linux,python-2.7,terminal,virtualenv

You have to activate the virtualenv in every shell, or, as 0range suggested, activate it in your .bashrc or any script running before your shell displays the prompt. To add it to your .bashrc : Edit /home/youruser/.bashrc and add the line : source /path/to/bin/activate Open a new shell or source...

Why is it slower to print directly to console/terminal than redirecting?

linux,io,terminal

Primarily, terminals are just plain slow. For every update, they have to: Parse and interpret any control codes. Parse, interpret and render any escape codes. Interpret and account for any multibyte and composed characters. Update appropriate screen and scroll buffers. Render this with appropriate fonts. and possibly do all of...

Delay packets using Netem on Virtual Machine

ubuntu,networking,terminal,virtualbox

I looked around and realized I needed to use the sudo command so I added sudo before the "tc qdisc..." I'm fairly new to linux so I don't know many stuff. My bad!

terminal command for running sublime text 3 from on ubuntu

linux,ubuntu,terminal

As per Mathias comment in my question I found the answer here... How can I open Sublime Text 2 files from the command line in linux to a tab, not a new window...

Eclipse CDT - No Console Output on OSX

c++,eclipse,osx,terminal,64bit

Are you using the right compiler? If you are compiling with Cross GCC it might not run on a 64bit OS X device. Try using MacOS GCC for compiling if so.

How do I force jquery terminal to remain the same size?

jquery,scroll,terminal,position,jquery-terminal

Add a height option: JS $('#terminal').terminal(function (command, term) { if (command == 'test') { term.echo("you just typed 'test'"); } else { term.echo('unknown command'); } }, { prompt: '>', name: 'test', height: 200 }); Demo: http://jsfiddle.net/11o3spLd/...

Extract string with grouping in regular expression on terminal

regex,linux,bash,terminal

You can do the following: grep -oP "(?<=\">).*(?=</a)" your_file This will print: Lab: K-means Clustering Lab: Hierarchical Clustering Interview with John Chambers Interview with Bradley Efron Interview with Jerome Friedman Interviews with statistics graduate students Since there's no easy way to print only captured groups using grep, I used lookahead...

Issue with Mac OSX Terminal, shows special character codes like space, brakets

osx,utf-8,terminal

Issue has been caused due to localedef I am able to confirm post getting a reply from Apple Support team. As per the support team instruction I created a New User Account and checked terminal. With new account terminal worked well. Best solution is New User Account if we want...

having trouble with piping multiple times

bash,terminal

bash doesn't let you redirect stdout twice. Instead, redirect stdout and stderr separately: ./program input.txt > output.txt 2> log ...

How to print combined words on terminal?

printing,terminal,zsh

This is called ASCII art. Have a look at this thread, might give you an idea how it works and how you come up with images/graphics like that. After you know what you want to print, you can simply output it like any other string....

rake db:seed yields syntax error, unexpected '\n', expecting => [closed]

ruby-on-rails,ruby,terminal,syntax-error,rake

You have a typo on line 16th: Location.create(area: 'College Ave', should be Location.create(area: 'College Ave') ...

“Error: Could not find or load main class” JavaFX Terminal

java,ubuntu,javafx,terminal,javafx-8

You are missing the package while firing java command. (Implied from the comments, since it is not included in the question) After compiling, navigate back to src folder and append the package to your class name : java com.jdojo.intro.HelloFXApp ...

How do i make a condition that will end the program, and prevent further cout statements?

c++,terminal

I would suggest you use switch case for the conditions and a while loop for the enter 1,2,3 thing.. Something like bool running=true; while(running) { running = false; switch(i) { case 1: stuff; break; case 2: stuff; break; case 3: stuff; break; default: cout<<"enter 1,2,3"; running = true; } }...

How to execute a mongo command in sh file?

mongodb,terminal

Here is the situation: which mongod would give you the path to the mongod binary. If there is no output from which, there which could not find mongod. This may be the case that there is not path in the $PATH variable, that contains the mongod binary. You can make...

Compiling C++ code from vim

c++,linux,vim,terminal

The :compiler command selects a compiler plugin; there's one named gcc, but none named g++. That's the E666 you get. You can obtain a list of all installed compiler plugins by typing :compiler followed by <C-D> (lists all) or <Tab> (completion). Note that compilation of C/C++ source code is usually...

Iterate over specific files in a directory using Bash find

bash,command-line,terminal

In line one: What is '' file? According to help read, that '' is an argument to the -d parameter: -d delim continue until the first character of DELIM is read, rather than newline In line six: What does the empty space do in < < (find). There are...

How to check whether std::cout support colors?

c++,terminal

There is no portable way to determine if a given device supports colors. There are several programming interfaces (some portable, some not) which attempt to determine this information, but rely upon being configured properly. For instance, curses (including ncurses) relies upon your setting TERM correctly to tell the library what...

Shorten Error Message in Terminal

ruby-on-rails,ruby,error-handling,terminal

You could try better_errors gem. It provides also a better explanation of the errors via browser. This is the link to the github repo EDIT If you are looking also to a customizable console (also the exception trace) try to see pry...

Python (3.4) run SSH commands on local terminal [closed]

python,ssh,terminal

You might be looking for the subprocess module. You can do (for example): subprocess.call("<bash command here>", shell = True) For more details check the documentation....

How do I edit $PATH (.bash_profile) on OSX?

osx,path,terminal,osx-yosemite

You have to open that file with a text editor and then save it. touch ~/.bash_profile; open ~/.bash_profile It will open the file with TextEdit, paste your things and then save it. If you open it again you'll find your edits. You can use other editors: nano ~/.bash_profile mate ~/.bash_profile...

Patch scrolling back in suckless ST terminal to support mouse wheel

c,unix,terminal,x11

It is not that simple. This question occasionally arises when someone wants left/right scrolling for a mouse trackball. On the left column of the tables is an X event. Those are limited to combinations of predefined symbols. Button4 and Button5 are mentioned because those are conventionally used to pass the...

Using Yeoman aspnet generators (Updated)

asp.net,terminal,yeoman,yeoman-generator,yosemite

You need to change the permissions of your usr/local folders by running the following code: sudo chown -R $USER /usr/local sudo chown -R yourUsername ~/.npm npm install -g yo grunt-cli bower Once you have completed this step, reset the generator-aspnet by running the following lines of code: npm install -g...

How should I add a stationary progress bar to a C++ program that produces terminal output (in Linux)?

c++,linux,terminal,progress-bar

The only portable way of moving the cursor around that I know of is using \r to move to the beginning of the line. You mention that you would like to output stuff above the progress. Fortunately, you are in luck since you're on Linux and you can use the...

How to get CPU utilization in % in terminal (mac)

osx,terminal,cpu

This works on a Mac (includes the %): ps -A -o %cpu | awk '{s+=$1} END {print s "%"}' To break this down a bit: ps is the process status tool. Most *nix like operating systems support it. There are a few flags we want to pass to it: -A...

How to get Mouse support for dtterm terminal in solaris

terminal,solaris,gnu-screen

There is more than one problem: xtermc does not match any terminal that you are likely to encounter (noted in xterm FAQ What $TERM should I use? dtterm does not match xtermc either (use infocmp xtermc dtterm to see). Sun stopped providing up-to-date terminal entries about 20 years ago. Perhaps...

Is there a way to go two directories back in cygwin (linux)?

terminal,cygwin,cd

You can use pushd and popd. pushd adds a directory to stack, popd removes it. See man bash for details.

How to find only the total RAM in Python

python,linux,shell,terminal,command

This will give you the total memory: echo $(cat /proc/meminfo |grep MemTotal) |grep -oE "[0-9]*" This one free memory: echo $(cat /proc/meminfo |grep MemFree) |grep -oE "[0-9]*" This one Active memory: echo $(cat /proc/meminfo |grep Active) |grep -oE "[0-9]*" You can extract all the information you need from /proc/meminfo like...

How do I get mdfind to include folder matches in addition to files?

osx,bash,terminal

tl; dr Use the following, locale-independent commands: files and folders: mdfind 'kMDItemUserTags == Red' files only: mdfind 'kMDItemUserTags == Red && ! kMDItemContentType == public.folder' folders only: mdfind 'kMDItemUserTags == Red && kMDItemContentType == public.folder' Simpler, but locale-specific equivalents - these only work in English-language locales and must be localized...

loop through different arguments in Rscript within Korn shell

r,terminal,ksh

You need to do two things: Create an array of all your input variables Loop through the array and initiate all your calls The following illustrates the concept: #!/bin/ksh #Create array of inputs - space separator inputs=(Input1 Input2 Input3 Input4) # Loop through all the array items {0 ... n-1}...

Using a command-line utility to perform the following map-updates

shell,command-line,awk,terminal

If order is not important, join and awk can do the job easily. $ join <(sort input.txt) <(sort mapping.txt) | awk -v OFS="|" '{for (i=3;i<NF;i++) print $2, $i OFS}' 103823054|001| 103823044|011| 103823044|012| 103823044|013| 103823064|011| 103823064|012| 103823064|013| ...

Which Linux command determines if message queues or shared memory are in use?

c,linux,terminal

I think you need ipcs. You can find more informations there : http://www.makelinux.net/alp/035 http://linuxcommand.org/man_pages/ipcs8.html ...

Do executable files always open a terminal window on MacOS?

osx,terminal,executable,app-bundle

I believe what you're seeing is correct. In order for a separate window to not pop-up, you'd need to encapsulate it into a bundle. Launching by double-clicking a bundle, or using the 'open' command from Terminal uses Apple's Launch Services, which maintains a list of known (registered) applications. When an...

How Do I make Date a Variable?

bash,shell,variables,if-statement,terminal

Using your code something like this is what you could use SpecficStatus="Pass" #SetVariable timestamp() { date +"%T %D"; } SpecficDate=$(timestamp) echo $SpecficStatus echo $SpecficDate ...

Programmatically changing color scheme for Xcode through Terminal

xcode,shell,terminal

The defaults command can be used to modify Xcode preferences: term> defaults write com.apple.dt.Xcode.plist Xcode3BuildRulesEditorDisplayMode 1 As Naoto Ida mentioned, changes here will most likely not effect Xcode until it's relaunched....

How to make a scrolling menu in python-curses

python,terminal,curses,python-curses

This code allows you to create a little menu in a box from a list of strings. You can also use this code getting the list of strings from a sqlite query or from a csv file. To edit the max number of rows of the menu you just have...

Why can't I access my vi folder?

mongodb,path,terminal,root,cd

The problem is with your $PATH variable. You have broken it, so bash does not find any utility out of your current working directory. To fix your issue you can execute vi directly with the absolute path: $ /usr/bin/vi ~/.bash_profile Then edit your $PATH declaration line: export PATH="/Users/james.flan/Documents/Software/MongoDB/bin:$PATH" Then you...

How do I find out exact characters in a text input or file?

bash,terminal

Try diff a b | od -tx1 or some variant...

cd command stopped working when not in su mode in terminal [closed]

linux,bash,terminal

There are an alias: alias cd='cd /home/l_name' that mades unusable the "cd" functionality, redirecting all "cd" commands to "/home/l_name"...

Why I'm getting different java versions

java,terminal,java-8

Could it be that you installed the JRE 8 update 45 but still have version 8 update 31 for JDK?

Excel vlookup-like command line function or tool?

osx,bash,replace,command-line,terminal

awk seems like the tool for the job: awk 'NR == FNR { a[$1] = $2; next } FNR == 1 { FS = "|"; OFS = FS; $0 = $0 } { $2 = a[$2] } 1' mapfile datafile The code works as follows: NR == FNR { #...

nano: Move forwards/backwards one word with META+Left / META+Right

unix,terminal,nano

According to the manual page for nanorc, you cannot do this. It does not accept bindings for special keys modified by meta. This is what it says regarding M- (the meta-modifier): M- followed by a printable character or the word "Space". Example: M-C A similar question was asked in Bind...

Error when trying to run carthage

ios,swift,terminal,carthage

I found the solution here : https://github.com/Carthage/Carthage/issues/330 Steps: sudo rm -rf /Library/Frameworks/CarthageKit.framework rm -f /usr/local/bin/carthage brew uninstall carthage brew install carthage ...

C++: Re-use line printed to console [duplicate]

c++,terminal,console,formatting,output

You can either print the "="s without a line break or you can use ncurses which I think also wget uses. But in my opinion ncurses is much work to do. For small Projects I recommend the simpler way....

Executing a Linux command in Terminal from Java

java,eclipse,ubuntu,terminal,virtuoso

I have had a hard time trying to get commands run using Runtime.exec() in the past. Anyways I have shifted to using ProcessBuilder as follows: ProcessBuilder pbuilder = new ProcessBuilder("bash", "-c", <<your command as string>>); File err = new File("err.txt"); try { pbuilder.redirectError(err); Process p = pbuilder.start(); p.waitFor(); } catch...

Error in reading Ubuntu 14.04 mouse event file (/dev/input/event3) with java programmig

java,events,ubuntu,terminal,mouse

Check that your buffer size is correct. In recent Linux kernels size of input_event structure is dependent on many things, but mainly on cpu architecture. Here's its declaration: struct input_event { struct timeval time; __u16 type; __u16 code; __s32 value; }; On 32-bit systems it's very likely that your buffer...

Script to get List of logged in users

linux,shell,scripting,terminal

Try doing this in single one awk statement: who | awk '{print "The user " $1 " is on " $2}' By doing that many piping, you are sending first one's input as another ones output. Hence you are losing previous data and at last only the output of who...

Trouble running C++ through terminal in Ubuntu

c++,linux,ubuntu,gcc,terminal

The errors that you are getting are because the cout is not in the global namespace rather it is in std namespace. Well instead of writing using namespace std; after #include <iostream> try using: using std::cout; since using first option is a bad practice. You can refer to Why is...

Trim audio file and get the part between silence

linux,audio,terminal,speech,sox

I believe that what you are looking for can be achieved with a sox silence command. It allows you to remove the silence from any part of the audio given a threshold, durations above it, etc. For a detailed manual please refer to the sox webpage, the silence section is...

Is there a way to save a mac terminal output directly to a file?

excel,osx,terminal

Imagine your mysterious program is called fred and you run it by typing ./fred in the Terminal. Now, you can make the output get sent into a file called file.txt by running it like this: ./fred > file.txt Now, you can copy the first 10 lines of the file by...

Receiving an error upon heroku login not sure why permission seems to be the issue

git,heroku,terminal

When you run heroku login command, it will write your Heroku API key to the .netrc file. If you first run sudo heroku login, then the .netrc file will be owned by the root account and not your user account. Unless you change permissions on the file using chmod a+x...

C passing terminal commands and print answer

c,variables,terminal

system doesn't return the output the command you run but simply returns the exit status. You probably want to use popen() to read the output of the command you run. See an example in the linked man page. You also need to use strcmp for comparing strings, not ==....

Terminal says 'No such file or directory' when open

osx,git,bash,terminal

The first line of your .bash_profile is the problem. That line is attempting to run /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin as a command which causes the error you see when you start the shell. Remove that line and the error should go away....

Terminal line resetting after about 50 characters

terminal

The usual reason for this is due to not quoting escape sequences used to color or highlight your prompt in the bash shell. If you do not do that, bash counts the escape characters as "printing". The same would apply for zsh (different quoting), but bash happens to be the...

when install cocoapods get Error?

terminal,cocoapods

You need to be root to write into /Library, so you need to use sudo, as the instructions tell you: $ sudo gem install cocoapods ...

Macports switch PHP CLI version

php,bash,drupal,terminal,macports

Do not modify files in /usr/bin. That's Apple's turf, and there are always other possibilities to avoid changing things there, especially since Apple's next update will happily revert these changes again and scripts might rely on /usr/bin/php being exactly the version Apple shipped with the OS. Put the original binary...

reverse every other line in a file, write to a new file in unix [closed]

python,perl,unix,awk,terminal

Use Perl's options to assemble a oneliner. perl -lpe '$_ = reverse $_ unless $.%2' file -l (lowercase L) chops off the terminating newline and adds it back on when printing; -p causes Perl to loop over input lines and print each after running the script on it; $_ is...

How do I open file list outputted from find command?

osx,bash,terminal

You were close with your second attempt. To substitute the output of a command into a command line, you use $( command ). open -a TextEdit $(find . -type f | gshuf -n2) However, this won't work properly if any of the filenames have spaces in their names, because each...

How to run multiple brew commands with one line

osx,bash,shell,terminal,homebrew

Easily done. Just add a semi colon. So.... brew update; brew upgrade; brew cleanup; This is the basics of writing your own BASH scripts. You can write complex scripts that are a single line. echo thanks this is a test; echo ok here is new line, echo run another command...

Runtime.getRuntime().exec() doesn't execute some commands

java,linux,terminal

The cd command is a shell built-in command. There is no shell when you run a command via exec(...). Indeed, if you try to find a cd command in any of your system's bin directories, you won't find one ... because it is impossible to implement as a regular command....

Unable to install jade in a node.js project

node.js,osx,terminal,jade

You are using a non supported npm and an old nodejs version, please upgrade node (npm is embedded) ans try again. https://nodejs.org/download/

When was a file used by another program

osx,performance,terminal,stata

From the OS X terminal, cd to the directory containing the CSV files, and run the command ls -lUt | head which should show your files, sorted by the most recent access time, limited to the 10 most recently accessed....

Keep stdin line at top or bottom of terminal screen

python,terminal,curses

Here is a basic example: Code: #!/usr/bin/env python from string import printable from curses import erasechar, wrapper PRINTABLE = map(ord, printable) def input(stdscr): ERASE = input.ERASE = getattr(input, "ERASE", ord(erasechar())) Y, X = stdscr.getyx() s = [] while True: c = stdscr.getch() if c in (13, 10): break elif c...

(SOLVED) Not working scp command: Connection closed by remote host (Mac OS X)

osx,unix,terminal,scp

I just had the same issues with an SCP from my personal Mac to a Mac desktop we use as a local server. Running sudo sshd -t showed me the following hint: /var/empty must be owned by root and not group or world-writable All I did was change the owner...

code . shortcut fails on OSX

osx,terminal,vscode

Make sure you have Visual Studio Code 0.3.0 installed. We recently changed the bundle identifier!

When to use quotes in command line? cp versus find

command-line,terminal,quotes,double-quotes,cp

You need quotes if you don't want the shell expanding the arguments, but instead want the argument passed through verbatim to whatever program you're trying to run. See, for example, the following program: #include <stdio.h> int main (int argc, char *argv[]) { printf ("Argument count = %d\n", argc); for (int...

How to exit if statement in bash without exiting program?

bash,terminal

First: Don't do any of this. Structure your program some other way. If you described to us why you think you need this behavior, we could potentially have told you how to achieve it otherwise. Getting down to the question: If you wrap your block in a loop, you can...

If/Else Statement's Shell Comparing more than 2 Values?

bash,shell,date,if-statement,terminal

You have to use two conditions: if [ "$TodaysDate" = "$prevDate" ] && [ "$TodaysDate" = "$currDate" ] ; then or the -a operator (not recommended) if [ "$TodaysDate" = "$prevDate" -a "$TodaysDate" = "$currDate" ] ; then or, if you're in bash, switch to [[ ... ]] conditions: if...

CLion cout opens command prompt window instead of using CLion's terminal

c++,terminal,command-prompt,cout,clion

Fixed it. CLion can't properly handle missing DLL files and although I had a lib inside my MinGW lib folder, windows wasn't finding it and thus the application was erroring. I moved the DLL to my windows folder and now it works fine....

Error installing Gulp

node.js,terminal,gulp,taskmanager

Other answers are bypassing these issues by the use of sudo or su root. I personally don't recommend this. The reason it works is because on OSX the global npm module directory has stricter permissions. Running your commands with root privileges just to get around permissions issues is likely only...

Mac Terminal Auto Complete

osx,terminal

Put this in your ~/.inputrc: set show-all-if-ambiguous on You'll need to restart your shell (for example by opening a new terminal window or typing exec /bin/bash)....

Where can I read the ANSI terminal standard?

terminal,standards

I think I found what I'm looking for. According to WikiPedia's ANSI escape code, the standard adopted was ECMA-48, the document is available at www.ecma-international.org Ecma-048.pdf

Whats wrong with my Mongo query?

mongodb,terminal,vi,hybrid-mobile-app,.bash-profile

Check your /etc/hosts for localhost entry and also make sure that mongod is listening to all interfaces, you can check by netstat -an|grep mongo.

How to enable branch hints in Mac OS git?

osx,git,terminal

You have to install git-autocomplete which can be get with homebrew: Install Git and bash-completion: brew install git bash-completion (Note: If this install fails with a 404 error, and you already have git installed, just remove the git part of this brew install) Add bash-completion to your .bash_profile: if [...

How to get all the output in terminal

linux,ubuntu,terminal,output,execute

The easiest way to capture all of the output to the terminal is using script, e.g., script -c "somecommand arguments" writes the output of "somecommand arguments" to the file typescript. If the program that you are running prompts for input, script will not interfere with that....

how to get multiple column layout for terminal on mac?

osx,terminal

OS X terminal doesn't have the option to split panes vertically. It is only possible to split horizontally. I recommend using iTerm2 on OS X. It has a lot of features missing in default terminal, including possibility to split windows both horizontally and vertically. ...

How to change terminal background to photo in OS X

osx,terminal,background-image,osascript

Unless something has changed, OS X does not expose the background image property to osascript. However, you can do the following: osascript -e 'tell application "Terminal" to set background color of first window to {0,17655,0,-16373}' So, you could change the color via script. If you really want an image, though,...

xargs echo colored output

terminal,xargs

Perhaps this is for Linux (although OSX adds an interesting twist by reversing the roles of bash and echo). Linux's /bin/echo has a -e option which expands escapes of the sort you show, while some shells (such as dash, used in Debian) follow POSIX more closely, and do not do...

How to copy files and add prefix at the same time?

osx,bash,terminal,command

This solution is not perfect but it should do what you want (assuming I understood your question correctly): Create a file doCopy.sh with the following content: #!/bin/bash origName=$1 newName=$(echo $origName | sed -e 's|/|.|g') echo cp $origName $newName Then make it executable and call it for each of your files:...

remove the first 15 characters from every other line in a file

bash,unix,terminal,bioinformatics,qiime

If you don't mind using sedand assuming other line starts with > then the following will remove the first 15 contiguous uppercase characters "A-Z" of the other lines: sed 's/^[A-Z]\{15\}//' file > new_file Or, in place edit (GNU sed) use -i: sed -i 's/^[A-Z]\{15\}//' file Or, in place edit (BSD...

Python modules not found over terminal but on python shell, Linux

python,linux,ubuntu,terminal

It seems that your Python shell uses a diffenrent PYTHONPATH than the python you execute in the terminal. You can verify that by typing import sys print sys.path in both shells and comparing the two outputs. I assume that the installed module path(s) are missing in the output of the...

“which nvm” command (nvm installed via homebrew) doesn't return path

terminal,homebrew,nvm

Doing source $(brew --prefix nvm)/nvm.sh exports nvm() function into your shell environment. It's not a reference to an executable, but the function whose contents you see when you do which nvm.

“nvm” command not recognized in new command line windows/tabs despite presence of “NVM_DIR” variable in both ~/.bashrc and ~/.bash_profile

node.js,osx,unix,terminal,nvm

The instructions from brew after installing nvm are: Add the following to $HOME/.bashrc, $HOME/.zshrc, or your shell's equivalent configuration file: source $(brew --prefix nvm)/nvm.sh On OS X with default settings, you actually want $HOME/.profile (or ~/.profile). Just add the line above to the end of that file. Running that line...

How can I run a command line command from within a ruby file?

ruby,file,terminal,command

cmd = "ls > somefile.txt" system( cmd ) or even just simply system( "ls" ) Thus, you can use system....

Generate a Salted Hash in Terminal

hash,terminal,applescript,osx-mavericks

From what I understand, at least conceptually, what you're asking for requires 2 steps: Obtain a random salt value. Concatenate the salt value with the input text (password) and compute the hash for the combined value. For later verification, you'll have to store the salt along with the resulting hash....

Python command line arguments linux

python,linux,command-line,terminal,arguments

It should be sys.argv[1] not sys.argv[0]: filearg = sys.argv[1] From the docs: The list of command line arguments passed to a Python script. argv[0] is the script name (it is operating system dependent whether this is a full pathname or not). If the command was executed using the -c command...

Run python function from terminal

python,osx,bash,terminal

test sample: └> cat hello.py class Hello: def hello(self): print "hello" └> python -c 'from hello import Hello; h= Hello(); h.hello()' hello └> python -c 'import hello; h= hello.Hello(); h.hello()' hello you can choose either import mypackage.mymodule or from mypackage.mymodule import myclass python -c 'from lighting import OfficeLights; lights =...

Installing gphoto2 on mac os x Yosemite - issue with ./configure

xcode,osx,terminal,libgphoto2

I wouldn't bother faffing around with building it yourself. I would install homebrew from here. Then you can simply do brew install gphoto2 and you will also have a decent package manager if you want to install other cool stuff later on - e.g. ImageMagick, gawk, GNU sed, swatch, youtube-downloader,...

How to list the contents of a subdirectory after finding the directory

linux,bash,terminal

I guess you could use something like this: find . -maxdepth 2 -type d -name "MWACluster15" -execdir ls {}/logs/ \; -execdir executes a command from the directory in which the directory you're interested in is found. The {} is a placeholder which is substituted with the directory name "MWACluster15"....

Bash program/wrapper that allows you to edit with arrow/delete keys

linux,osx,bash,terminal

rlwrap is a wrapper program to allow CLI commands that prompt for input use the readline library without having to link against it.

Replace multiline string in all files in terminal

regex,perl,terminal

You can use: s/(^\s*^\/\/###==###.*?\/\/###==###\s*)//gms Working Demo Then in the terminal and in Perl. Given: $ echo "$tgt" Text to keep //###==### Text to remove //###==### Text to keep Use the -0777 command flag to slurp the whole file and then: $ echo "$tgt" | perl -0777 -ple 's/(^\s*^\/\/###==###.*?\/\/###==###\s*)//gms' Text to...

provide custom terminal session to incoming ssh connections in c++

c++,unix,ssh,terminal

sshd of course is configurable, and can be made to listen on different ports. These discuss it at length: Change the default SSH port Getting SSH to listen to different ports on different interfaces The underlying issue is what would one do with this. That has been asked before, with...