terminal

Execute C program till Ctrl+C hit in the terminal

时光怂恿深爱的人放手 提交于 2019-12-23 17:43:38
问题 I am writing a program that repeatedly does an operation till Ctrl+C is hit by the user in the Linux terminal. I am programming in C. Any ideas how i can implement this. I have tested my program by using "for" loops with a condition but now i want to make it run as long as Ctrl+C is hit by the user and interrupted. What I was thinking was of writing a do while loop like the following do{ / Computation / } while(Ctrl+C is not hit) But i dont know how to check for the Ctrl+C input from the user

Executing Python Script From Command Line is Hiding Print Statements

六月ゝ 毕业季﹏ 提交于 2019-12-23 16:46:55
问题 I know this must be a super basic question, however, I have tried finding a simple answer throughout SO and cannot find one. So my question is this: How can I execute a python script from the command line such that I can see print statements. For example, say I have the file test.py: def hello(): print "hello" If I enter the interpreter, import test.py, and then call test.hello(), everything works fine. However, I want to be able to just run python test.py from the command line and have it

How to execute the “help” Linux command on Android?

北战南征 提交于 2019-12-23 16:13:26
问题 I would like to run a command like am -help and get usage information for that command. However, the -help parameter does not seem to work on the Process Runtime. How to make this work? cmd1[0] = "/system/bin/sh"; cmd1[1] = "-c"; cmd1[2] = "/system/bin/am -help" //I want to do sth like this Process process = Runtime.getRuntime().exec(cmd1); The command works without the -help . Is there any way of getting Android Shell commmands' usage information and/or syntaxes? Note that if I don't send am

Error with “sudo apt-get”, dictionnary-commons since update to Ubuntu 14.04

﹥>﹥吖頭↗ 提交于 2019-12-23 15:17:35
问题 You can see below the error I encounter. I did search on Google if the question has already been asked (and answered) but nothing works for me. I can't do sudo apt-get install ... Thank you in advance if someone can help me with this situation. Regards, David david@09:25:47 ~$sudo apt-get upgrade [sudo] password for david: Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not

How to change text color & background in mac terminal?

a 夏天 提交于 2019-12-23 14:55:39
问题 I'm writing a program that needs to write text in different colors. I have the escape code RED " \e[31m". However, if I make red on a red background, that won't work. So I also want to change the background color. I've tried using this "\e[31m\e[94m " or even \e[4Xm to do text on a different background, however, this isn't working. Any ideas to get red text on a white background? This is in the format std::cout << "COLORNAME" .... Thanks! 回答1: Multiple SGR options can be chained together, and

Linux Rename file with only time/date stamp

落爺英雄遲暮 提交于 2019-12-23 13:38:07
问题 I have a single file which I want to rename mv to year_month_day_h:m:s - whats the best way to do that? I've tried the following but it doesn't dynamically add the correct stamp (original file actually has a backslash in the name): mv getnw/myfilename.txt "%Y%m%d%H%M%S".txt mv getnw/myfilename.txt "%Y-%m%d%H%M%S".txt mv getnw/myfilename.txt %Y-%m%d%H%M%S.txt mv getnw/myfilename.txt "'date +%Y%m%d%H%M%S'.txt" 回答1: mv myfile.txt `date +%Y_%m_%d_%H:%M:%S`.txt 回答2: mv myfile.txt myfile`date -Is`

GruntJS “bus error grunt watch”

≯℡__Kan透↙ 提交于 2019-12-23 11:51:42
问题 I'm having an error with GruntJS when I try to run a grunt watch . It works fine, until there is a change in the file it is watching, then, it looks something like this: Running "watch" task Waiting...[1] 2464 bus error grunt watch The number 2464 changes. It seems to be the port that grunt is watching on? But, I'm not sure. Here is my Gruntfile: module.exports = function (grunt) { "use strict"; grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), sass: { dist: { options: { style:

Erase Safari cookies from Terminal

荒凉一梦 提交于 2019-12-23 10:53:21
问题 I am making an application that involves controlling Safari from Applescript. Is there a way in the Terminal (preferred) or Applescript to erase Safari's cookies. Basically I want to the "Reset Safari" item from the menu using the Terminal. Is there a method that can do this? 回答1: You could simply delete the Cookies.plist file: rm ~/Library/Cookies/Cookies.plist Or take a look at this: List & delete Safari cookies 回答2: Reset Safari does more than just erasing the cookies: Basically I want to

How to run TKDiff from the terminal on mac os

荒凉一梦 提交于 2019-12-23 10:02:12
问题 I downloaded TKDiff from http://tkdiff.sourceforge.net I would like to use it from the terminal like i'm using the regular diff. something like: tkdiff file1.txt file2.txt can anybody help me with that? thanks! 回答1: Use the homebrew version. First install brew (http://brew.sh), then brew install tkdiff then it should just work 来源: https://stackoverflow.com/questions/16318592/how-to-run-tkdiff-from-the-terminal-on-mac-os

tesseract install mac os

半世苍凉 提交于 2019-12-23 09:56:01
问题 I am trying to install tesseract on my mac using homeBrew. When I try installing, everything seems to be good but I get the following error/message: Warning: Could not link leptonica. Unlinking... Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local You can try again using `brew link leptonica' When I try running a tesseract function, I get the following error: Tesseract Open Source OCR Engine v3.02.02 with Leptonica Error in