terminal

Input from the execution line in the terminal in c

 ̄綄美尐妖づ 提交于 2019-12-25 02:42:54
问题 The problem that i have is that i have to write a hanois tower game in c and the input for the number of the rings must not be in the programm but the code must read the number of rings in the execution. Example: ./ hanoistower 3 And the code should get the 3 as the input. How can i do that? 回答1: Command line arguments are propagated as strings through the main() function of your C program. In int main(int argc, char *argv[]) argc is the number of arguments, and argv is an array of strings

How to open Terminal and execute command using java code in OSX

。_饼干妹妹 提交于 2019-12-25 02:31:38
问题 How to launch terminal and execute some commands using java code in MAC? Similar question i have found for LINUX OS from below link. how to run a command at terminal from java program? 回答1: It worked same as Linux, Runtime.getRuntime().exec("rm filename"); Thanks @ginz 回答2: You need to run it using bash executable like this: Runtime.getRuntime().exec("/bin/bash -c **YouTerminalSoftWareName**"); YouTerminalSoftWareName must be absolute path or aready in your PATH environment variable 回答3: Use

I/O redirection differences between zsh and bash

一笑奈何 提交于 2019-12-25 02:29:54
问题 I use zsh at the command-line but the shell scripts I write run bash so that they are portable. I was learning about IO redirection from here when I realized this difference: Note that the command is just an arbitrary one whose first line of output is over stderr and the second line comes over stdout. zsh on OS X: % ls -ld /tmp /tnt 1>&2 2>&1 | sed -e 's/^/++/' ls: /tnt: No such file or directory ++ls: /tnt: No such file or directory lrwxr-xr-x@ 1 root wheel 11 Oct 19 2012 /tmp -> private/tmp

Printing multi-byte characters in terminal using C

牧云@^-^@ 提交于 2019-12-25 02:29:26
问题 I've been experimenting with a custom string object (struct) which looks like this: typedef struct { int encoding; int length; character * array; } EncodedString; The idea is that by specifying the encoding, I can make a few functions which use that encoding to print the string correctly, i.e. ASCII or utf-8 or utf-16, etc. (Excuse my character encoding ignorance.) Right now, I'm trying to print out one (Mandarin) Chinese character: 狗 (0x72d7). I thought perhaps by printing it character by

is control-d a default stop sign for stdin? in linux C?

廉价感情. 提交于 2019-12-25 02:25:22
问题 is control-d a default stop sign for stdin? In our homework, it says command-d will be stop inputting. Is it a default ? 回答1: Ctrl-D on Linux terminal with default settings is an end-of-file marker for stdin. See also the tty demystified and the stty(1) command (and termios(3)...). Use e.g. feof(3) after some stdio operation, or compare the result of getc(3) with EOF (etc....) to detect end-of-file conditions! 来源: https://stackoverflow.com/questions/24548087/is-control-d-a-default-stop-sign

what does linux command “ps auwwx” mean? [closed]

断了今生、忘了曾经 提交于 2019-12-25 02:07:33
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . What does "auwwx" mean in the command "ps auwwx"? According to the "man ps" ps - report process status ps gives a snapshot of the current processes. If you want a repetitive update of this status, use top. This man page documents the /proc-based version of ps, or tries to. 回答1: The -w option sets the output to

Using the Command-line Command to launch Sublime Text 2 on OS X

北城余情 提交于 2019-12-25 01:48:36
问题 I just started reading Michael Hartl's book on Rails and I've run across a problem in the setup phase. Hartl keeps referring to making a file in my home directory, but I'm not quite sure how to do this. For example, when I try to setup the command line for sublime text the instructions tell me to do this: Assuming you've placed Sublime Text 2 in the Applications folder, and that you have a ~/bin directory in your path, you can run: ln -s "/Applications/Sublime Text 2.app/Contents

dialog (shell script program) but for C/C++ programs

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 00:15:56
问题 I'm looking for a library or something usable from C/C++ (cross-platform if possible) that does something similar to the program "dialog", which is/was available on most Linux systems. Basically, I would like a simple menu similar to dialog --menu , but I don't want to have to write too much code for it. Console-based is fine; does anyone know of such a library? By the way, does anyone know a good Google shortcut to search for the program "dialog" as opposed to GUI dialog boxes (e.g. "golang"

Passing Multiple Parameters from Applescript to Terminal Command Script

夙愿已清 提交于 2019-12-24 23:27:46
问题 I have been trying to figure out how to pass multiple parameters from an Applescript to a Terminal Command Script. For example when running a terminal command file you are able to receive parameters programatically like so: #!/bin/bash var=$1 var=$2 The Applescript Code that I have been working with is below for reference: tell application "System Events" to set app_directory to POSIX path of (container of (path to me)) set thisFile to "Dev" set testTarget to "/Users/lab/Desktop/TestTarget/"

How can i get the dates to fall on the perspective day?

与世无争的帅哥 提交于 2019-12-24 22:28:29
问题 How can i get the day/number go under each day? This is my code below: class Month attr_reader :month, :year def initialize( month, year) @month = month @year = year end def month_names names_of_months = {1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', 9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December'} return names_of_months[@month] end def length days_of_months = {1 => 31, 2 => 28, 3 => 31, 4 => 30, 5 => 31