terminal

How to automate the sending of files over the network using python?

大城市里の小女人 提交于 2020-01-14 06:12:31
问题 Here's what I need to do: I need to copy files over the network. The files to be copied is in the one machine and I need to send it to the remote machines. It should be automated and it should be made using python. I am quite familiar with os.popen and subprocess.Popen of python. I could use this to copy the files, BUT, the problem is once I have run the one-liner command (like the one shown below) scp xxx@localhost:file1.txt yyy@]192.168.104.XXX:file2.txt it will definitely ask for something

Comparing numbers in bash scripting

与世无争的帅哥 提交于 2020-01-14 05:17:07
问题 I wrote this script to compare 2 numbers in bash but it gives me wrong answers for some numbers. like if I give it 2&2 for input , it gives me "X is greater than Y" #!/bin/bash read num1 read num2 if [ $num1 > $num2 ] then echo "X is greater than Y" elif [ $num1 < $num2 ] then echo "X is less than Y" elif [ $num1 = $num2 ] then echo "X is equal to Y" fi 回答1: You can try with bash arithmetic contexts: #!/bin/bash read num1 read num2 if (( num1 > num2 )) then echo "X is greater than Y" elif ((

MacOS Terminal: how to use a seccond ssh key?

会有一股神秘感。 提交于 2020-01-13 20:37:37
问题 I'm working on MacOS and want an SSH/Git login with a seccond ssh-key. I have two key pairs in ~/.ssh/ id_rsa id_rsa.pub id_rsa.gitlab id_rsa.gitlab.pub id_rsa and id_rsa.pub are the older key. This key is working fine. But where the second key is needed, i can't login. It trys the first key and fails. Running this command ssh-add /Users/kevin/.ssh/id_rsa.gitlab helps. But after a reboot, it dosen't work anymore and i must run the command again. Is there a better solution as run this command

MacOS Terminal: how to use a seccond ssh key?

 ̄綄美尐妖づ 提交于 2020-01-13 20:37:34
问题 I'm working on MacOS and want an SSH/Git login with a seccond ssh-key. I have two key pairs in ~/.ssh/ id_rsa id_rsa.pub id_rsa.gitlab id_rsa.gitlab.pub id_rsa and id_rsa.pub are the older key. This key is working fine. But where the second key is needed, i can't login. It trys the first key and fails. Running this command ssh-add /Users/kevin/.ssh/id_rsa.gitlab helps. But after a reboot, it dosen't work anymore and i must run the command again. Is there a better solution as run this command

Compiling c code programatically in linux terminal gcc

喜欢而已 提交于 2020-01-13 19:52:10
问题 I'm writing a c program on Linux that writes text into a file. I'm having trouble where i'M trying to use system("gcc fileName.c") to compile the new document i created into an executable. The file is getting the following input: char Msg[100] = {"#include <stdio.h>\nint main();\n\nint main()\n{\n\n\treturn 0;\n}"}; clearly it has a main() function and yet it still gives me the following wall of error: /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 0 has

PhpStorm terminal : Cygwin colors does not work

旧街凉风 提交于 2020-01-13 19:19:29
问题 I have PhpStorm 2016.2 and I added Cygwin in the Shell path as follow : "C:\cygwin64\bin\env.exe" CHERE_INVOKING=1 /bin/bash.exe It's working well, but the colors do not work. For exemple I have ?[32m Name instead of having Name colored in green. I tried several things like adding the plugin Grep Console to have the support of ANSI Color, but didn't work. It's really hard to work with lines with multiple ANSI colors ?[39m ?[32m Scheme ?[39m ?[32m Host ?[39m ?[32m Path . Do not hesitate to ask

Change colors on executable files in the terminal (or iTerm2)

血红的双手。 提交于 2020-01-13 11:06:11
问题 How do I change it, so executable files don't have another color, compared to other files? I'm on macOS Sierra (10.12.6). It's the same, both in the regular Terminal: ... or in iTerm2: It's frustating to look at. If i write chmod -x [FILENAME] then it disappears. But I don't want to change if the files are executable or not, - I want to change the color of executable files. I want my files to look like this (regardless of if it's executable or not): 回答1: I tried correcting Anshuman's answer,

Running a JavaScript file in Chrome

只愿长相守 提交于 2020-01-13 10:42:09
问题 I would like to run a local javascript file in chrome console but do not want to copy and paste the code. I know there is a command I can run from terminal to open the file in a new chrome window/tab but cannot recall it nor find example of it on-line. What command can I call from the terminal to open a .js file in a new chrome tab where I can then run it in console? 回答1: I don't think you can do exactly that. To run JS with having access to the console, you can either copy its source to the

What is the meaning of the “bang” or “!” before the git command?

老子叫甜甜 提交于 2020-01-13 07:54:46
问题 As you can see from this excerpt, there is a "!" before the git command. What's the point? [alias] commitx = !git add . && git commit - https://stackoverflow.com/a/8956546/1354543 I understand aliases and what the command itself is doing, but not the point of the "!" before the git command. 回答1: The ! means "run the following as commands to the shell", so in this case the alias git commitx expands to the equivalent of running git add . && git commit (which is a terrible terrible idea) 回答2: An

Access /Private/etc with c

我与影子孤独终老i 提交于 2020-01-12 10:30:11
问题 this might be a simple question, but how do I "request" system / root priviliges from the user in a c console application. I need to write to /Private/etc but i can't. This is for mac / unix. I've seen it being used in other console commands e.g. when you run the following command: "sudo /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder", Terminal asks you for your Password. How do I do this? thanks, JNK 回答1: There isn't any system call which will let a process obtain root