terminal

How can I identify and handle control characters and arrow keys in Perl?

断了今生、忘了曾经 提交于 2020-01-02 07:38:12
问题 I want to implement the command line features like in a linux terminal. I saw this in ftp command also. If I press tab I need to list the commands. If I press control characters I need to get that characters based on that I will do some action. And if I give any commands it should execute. For this I tried with Term::ReadKey that is in non-canonical mode. But here I am facing more problems like if I press any control character or arrow I got three characters. For the up arrow I got ASCII 27

Trouble reinstalling mysql on OSX Mavericks

北战南征 提交于 2020-01-02 07:36:09
问题 I'm trying to reinstall mysql on my computer (os x mavericks) and I've done the following with the following errors: bash <(curl -Ls http://git.io/eUx7rg) Error: Starting MySQL ... ERROR! The server quit without updating PID file (/usr/local/mysql/data/christians-mbp.saumag.edu.pid). /usr/local/mysql/support-files/mysql.server: line 362: pidof: command not found /dev/fd/63: line 119: SORRY, MySQL IS NOT RUNNING ... THERE MUST BE A PROBLEM: command not found So I decided to see uninstall it if

Executing terminal commands from java

北战南征 提交于 2020-01-02 07:03:45
问题 I know there are many threads about this, but none of them worked for me. Here is what I am trying to do: Javac and run a file from my java code. It works for Windows but I would like to make it also work on UNIX. Here the code: if(os.equals("win")){ //For Windows try { Runtime.getRuntime().exec( "cmd /c start cmd.exe /K " + "\"cd " + path + "&& " + "javac " + name + ".java && " + "echo ^>^>" + name + ".java " + "outputs: &&" + "echo. &&" + "java " + name + " && " + "echo. &&" + "pause && " +

Executing terminal commands from java

淺唱寂寞╮ 提交于 2020-01-02 07:03:13
问题 I know there are many threads about this, but none of them worked for me. Here is what I am trying to do: Javac and run a file from my java code. It works for Windows but I would like to make it also work on UNIX. Here the code: if(os.equals("win")){ //For Windows try { Runtime.getRuntime().exec( "cmd /c start cmd.exe /K " + "\"cd " + path + "&& " + "javac " + name + ".java && " + "echo ^>^>" + name + ".java " + "outputs: &&" + "echo. &&" + "java " + name + " && " + "echo. &&" + "pause && " +

Run multiple commands in multiple Terminal windows with a single bash line

假如想象 提交于 2020-01-02 06:07:37
问题 Here's an interesting problem: Using the AppleScript method to launch a new command in a Terminal window fails if Terminal is "busy"; more precisely, it will open a new window but fail to run the command. For example, try copy+pasting this line in: osascript -e 'tell application "Terminal" to do script "foo"'; osascript -e 'tell application "Terminal" to do script "bar"'; osascript -e 'tell application "Terminal" to do script "baz"'; When I run this (I'm on Snow Leopard), I get three windows:

Pipe output of python script

蹲街弑〆低调 提交于 2020-01-02 05:15:14
问题 I'm running ./sample.py --url http://blah.com without error, though if I run ./sample.py --url http://blah.com | wc -l or similar I receive an error: UnicodeEncodeError: 'ascii' codec can't encode character u'\u200f' in position 0: ordinal not in range(128) How do I make a python script compatible with my terminal commands? I keep seeing reference to sys.stdin.isatty though its use case appears to be opposite. 回答1: When Python detects that it is printing to a terminal, sys.stdout.encoding is

DHT22 Sensor import Adafruit_DHT error

寵の児 提交于 2020-01-02 04:50:48
问题 So I've properly attached DHT22 Humidity Sensor to my BeagleBone Black Rev C. I'm running OS Mavericks on my MacBook Pro and I followed the directions provided by Adafruit on how to use my DHT22 The website I used was pretty clear: https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/software-install-updated Also here is the github files I cloned: https://github.com/adafruit/Adafruit_Python_DHT I put in these lines: git clone https://github.com/adafruit/Adafruit

Enabling italics in vim syntax highlighting for mac terminal

淺唱寂寞╮ 提交于 2020-01-02 01:35:11
问题 I'd like to have vim display my comments in italics, and I understand I need to place cterm=italic in the hi Comment line in the color.vim file I'm using. This, however, is having no effect on the text display, which I suspect has to do with some Terminal.app setting, unless I'm misunderstanding the vim syntax. I'd appreciate if someone can show me how to enable this feature. Additionally, I am currently using the Monaco font, which does not have a separate italic file (however, the italic

Replacing the null character ^@ in a flat file

有些话、适合烂在心里 提交于 2020-01-01 15:43:22
问题 I have a flat file generated from someone else's software. They insert the null character ^@ in certain positions of the file. I wish to replace them with something else like -9. How do I search and replace this character efficiently in terminal on Mac OS X? Thanks. There is another post addressing this question in linux. 回答1: (To maintain a SO tradition of proposing multiple answers with different tools for shell scripting questions): With tr : tr -d '\0' 回答2: With sed : sed 's/\x0/-9/g'

Better ruby terminal coloring library

梦想的初衷 提交于 2020-01-01 12:10:38
问题 There are plenty of coloring libraries: colored, term-ansicolor. But is there any which can do this: puts "#{'hello'.red} world!".bold And world! should be bold. To make it clear, I want to get this: "\e[1m\e[31mhello\e[0m\e[1m world!\e[0m" or better even this (just shorter): "\e[1;31mhello\e[0;1m world!\e[0m" instead of this: "\e[1m\e[31mhello\e[0m world!\e[0m" 回答1: As there is none, I wrote my own, with blackjack and hookers smart one — smart_colored gem install smart_colored and run