terminal

How do I detect whether sys.stdout is attached to terminal or not? [duplicate]

北慕城南 提交于 2019-12-28 03:21:30
问题 This question already has an answer here : How to recognize whether a script is running on a tty? (1 answer) Closed 6 years ago . Is there a way to detect whether sys.stdout is attached to a console terminal or not? For example, I want to be able to detect if foo.py is run via: $ python foo.py # user types this on console OR $ python foo.py > output.txt # redirection $ python foo.py | grep .... # pipe The reason I ask this question is that I want to make sure that my progressbar display

How do I detect whether sys.stdout is attached to terminal or not? [duplicate]

大兔子大兔子 提交于 2019-12-28 03:21:05
问题 This question already has an answer here : How to recognize whether a script is running on a tty? (1 answer) Closed 6 years ago . Is there a way to detect whether sys.stdout is attached to a console terminal or not? For example, I want to be able to detect if foo.py is run via: $ python foo.py # user types this on console OR $ python foo.py > output.txt # redirection $ python foo.py | grep .... # pipe The reason I ask this question is that I want to make sure that my progressbar display

how to run a command at terminal from java program?

纵然是瞬间 提交于 2019-12-27 21:07:31
问题 I need to run a command at terminal in Fedora 16 from a JAVA program. I tried using Runtime.getRuntime().exec("xterm"); but this just opens the terminal, i am unable to execute any command. I also tried this: OutputStream out = null; Process proc = new ProcessBuilder("xterm").start(); out = proc.getOutputStream(); out.write("any command".getBytes()); out.flush(); but still i can only open the terminal, but can't run the command. Any ideas as to how to do it? 回答1: You need to run it using bash

how to run a command at terminal from java program?

你离开我真会死。 提交于 2019-12-27 21:06:48
问题 I need to run a command at terminal in Fedora 16 from a JAVA program. I tried using Runtime.getRuntime().exec("xterm"); but this just opens the terminal, i am unable to execute any command. I also tried this: OutputStream out = null; Process proc = new ProcessBuilder("xterm").start(); out = proc.getOutputStream(); out.write("any command".getBytes()); out.flush(); but still i can only open the terminal, but can't run the command. Any ideas as to how to do it? 回答1: You need to run it using bash

how to run a command at terminal from java program?

孤者浪人 提交于 2019-12-27 21:06:45
问题 I need to run a command at terminal in Fedora 16 from a JAVA program. I tried using Runtime.getRuntime().exec("xterm"); but this just opens the terminal, i am unable to execute any command. I also tried this: OutputStream out = null; Process proc = new ProcessBuilder("xterm").start(); out = proc.getOutputStream(); out.write("any command".getBytes()); out.flush(); but still i can only open the terminal, but can't run the command. Any ideas as to how to do it? 回答1: You need to run it using bash

How to open the command prompt and insert commands using Java?

六眼飞鱼酱① 提交于 2019-12-27 10:21:42
问题 Is it possible to open the command prompt (and I guess any other terminal for other systems), and execute commands in the newly opened window? Currently what I have is this: Runtime rt = Runtime.getRuntime(); rt.exec(new String[]{"cmd.exe","/c","start"}); I've tried adding the next command after the "start", I've tried running another rt.exec containing my command, but I can't find a way to make it work. If it matters, I'm trying to run a command similar to this: java -flag -flag -cp terminal

Prevent Terminal resize python curses

ε祈祈猫儿з 提交于 2019-12-26 15:26:35
问题 I'm writing a program on python curses and I was wondering if there is a way to block terminal resizing in order to prevent curses' crashing both on Linux and Windows. This is what happens.. Can I prevent this? Under Windows this does not happen cause window resizing doesn't influence prompt proportions... http://alessio.ragno.info/Before%20Resize.png http://alessio.ragno.info/After%20Resize.png ` import curses screenTest = curses.initscr() boxTest = curses.newwin(24,80,0,0) boxTest.box()

Prevent Terminal resize python curses

旧街凉风 提交于 2019-12-26 15:26:05
问题 I'm writing a program on python curses and I was wondering if there is a way to block terminal resizing in order to prevent curses' crashing both on Linux and Windows. This is what happens.. Can I prevent this? Under Windows this does not happen cause window resizing doesn't influence prompt proportions... http://alessio.ragno.info/Before%20Resize.png http://alessio.ragno.info/After%20Resize.png ` import curses screenTest = curses.initscr() boxTest = curses.newwin(24,80,0,0) boxTest.box()

using Mac OSX “open” command to open URL with -n flag

北战南征 提交于 2019-12-26 04:21:29
问题 I'm having trouble getting /usr/bin/open to open a browser to a specific URL when using the -n flag. For example, this will work: open -a "Google Chrome" "https://stackoverflow.com" ...successfully opening the desired page. However, if my browser is already open, it will open it in an existing window as a tab. The man page for open says this should be remedied with the -n flag, but: open -n -a "Google Chrome" "https://stackoverflow.com" ...opens a new instance (window) of my browser to the

Opening a terminal with a terminal - Mac

瘦欲@ 提交于 2019-12-25 18:59:27
问题 I just need the command for opening a new terminal in a terminal and then being able to identify that terminal and then run some java code in that terminal. 回答1: I think you need to type this into a Terminal window, or put it in a script: osascript -e 'tell application "Terminal" to do script "/bin/date"' Change /bin/date to your Java thing. 来源: https://stackoverflow.com/questions/27866749/opening-a-terminal-with-a-terminal-mac