terminal

Java Process streams

安稳与你 提交于 2019-12-08 10:10:38
问题 I have a problem with interacting with some terminal application (in my situation it is openSSL). I have a command to send and then this application wants password and reply given password. My code doesn't work. I mean that I don't see any output from it. For testing I've made also simple application which is waiting for two strings to type and running it from my Java code works. Have you any suggestions? ProcessBuilder pb = new ProcessBuilder("openssl.exe"); Process process = pb.start();

SSH - Connect & Execute : “echo $SSH_CONNECTION | awk '{print $1}'”

落爺英雄遲暮 提交于 2019-12-08 09:38:09
问题 Here's my bash (shell?) script. command="ssh root@$ip"; command2="\"ls /;bash\""; xfce4-terminal -x sh -c "$command $command2; bash" connects to the server and executes the command of ls / works just fine. But instead of ls / .. I want to execute this command: echo $SSH_CONNECTION | awk '{print $1}' I replaced " ls / " with the code above, but soon as it connects, it simply prints a blank line. Based on my understanding, the code is being executed locally before it reaches the server because

In the macOS terminal, “ls | mdls” commands are only working for the home directory

老子叫甜甜 提交于 2019-12-08 09:23:28
问题 I would like a list of all the date added metadata for my Downloads folder on macOS. I found the following code (for macOS terminal) from http://forums.ilounge.com/applescripts-itunes-mac/100189-mdls-command-tiger.html, but it only works for the home directory. Adding a different directory as a modifier doesn't work, and using cd doesn't work. When I do those things, it still returns the results of the home directory. How do I get it to work for my Downloads folder, or is there another

How to programmatically tell if the terminal server service is running

孤者浪人 提交于 2019-12-08 08:49:05
问题 How can I programmatically tell if the terminal services service is running and is healthy? I'm creating a .net console application that will check if terminal services are running on a list of computers. I can check the remote registry entry to see if it's enabled, but that doesn't mean it's running. I was thinking of making a socket connection to port 3389, but it doesn't have to be listening on that port either. Is there an elegant way to check for this? Regards, 回答1: If you (or,

How to programmatically tell if the terminal server service is running

笑着哭i 提交于 2019-12-08 08:24:27
How can I programmatically tell if the terminal services service is running and is healthy? I'm creating a .net console application that will check if terminal services are running on a list of computers. I can check the remote registry entry to see if it's enabled, but that doesn't mean it's running. I was thinking of making a socket connection to port 3389, but it doesn't have to be listening on that port either. Is there an elegant way to check for this? Regards, If you (or, specifically, the user the application runs as) has permission to do so, you could remotely query the SCM of the

Java Redirecting Input and Output Stream of Terminal to GUI (JSch)

别说谁变了你拦得住时间么 提交于 2019-12-08 07:47:13
问题 I'm working on a project in which I intend to make a Java GUI application that connects to a ssh server and executes remote commands on the server. I'm willing to use JSch Library. My aim is to make buttons and textfields those will provide the user the ability of sending commands and getting replies easily. I mean, instead of opening xShell and prompting "grep "hi" /usr/file.txt", the user will choose the path from the list and will enter "hi" into the textfield and will press the button for

How to echo random amounts of dots mixed with spaces?

你说的曾经没有我的故事 提交于 2019-12-08 07:46:52
问题 I would like bash/terminal command to make it echo ... . . . . . . .. ...... .. . . . in other words random amounts of dots perhaps 100 dots max, mixed with spaces. how can this be done via bash script ? 回答1: Here is a one liner: max=$((RANDOM%100)); for ((i=0;i<max;i++)); do ((RANDOM%2)) && a="$a." || a="$a "; done; echo "$a" or in a more readable format: max=$((RANDOM%100)) for ((i=0;i<max;i++)) do ((RANDOM%2)) && a="$a." || a="$a " done echo "$a" 回答2: If you want the line to be really

How to run a lua file in cmd from Sublime Text 3?

雨燕双飞 提交于 2019-12-08 07:44:50
问题 I want to run lua files in cmd (for a reason I can't use build system). How can I do this? 回答1: Since you just want to call a cmd command you can easily write your own plugin. Just open your user directory and create a python file (e.g. run_lua.py ). Or just go with Tools >> New Plugin. This plugin runs the command lua $file and afterwards pauses until the user pressed a key: import subprocess import sublime_plugin class RunLuaCommand(sublime_plugin.WindowCommand): def run(self): view = self

Counter in Batch file for loop - how to keep the number in the same place? [duplicate]

别等时光非礼了梦想. 提交于 2019-12-08 07:38:11
问题 This question already has answers here : Windows batch: echo without new line (15 answers) Echoing in the same line (5 answers) Closed 3 years ago . I'm writing a batch file in Windows. I need to process a big text file line by line. I'd like to show a counter in the cmd window while doing this. The following code works pretty good: @echo off setlocal enableextensions enabledelayedexpansion set /a count=1 for /f "tokens=*" %%A in (myFile.txt) do ( set /a count+=1 echo.!count! ) The only

Problems with $SIG{WINCH} when using it in a module

半城伤御伤魂 提交于 2019-12-08 07:34:11
问题 When I use this module in a script, the if ( $size_changed ) { remains false when I've changed the terminal size. When I copy the code from the module directly in a script (so that I don't have to load the module) it works as expected. What could it be that loading the code as a module doesn't work? use warnings; use 5.014; package My_Package; use Exporter 'import'; our @EXPORT = qw(choose); my $size_changed; $SIG{WINCH} = sub { $size_changed = 1; }; sub choose { # ... # ... while ( 1 ) { my