shell

How to divide specific column with rest of columns

拈花ヽ惹草 提交于 2021-02-11 12:17:29
问题 I have matrix like this (first column names rest are values, separator i tab): name1 A1 B1 C1 D1 name2 A2 B2 C2 D2 Matrix could be huge (it is mean about hundreds rows and columns). It is allays same size. I can expect zero values. I need output like this: name1 A1 B1 C1 D1 A1/B1 A1/C1 A1/D1 name2 A2 B2 C2 D2 A2/B2 A2/C2 A2/D2 This combination save to new file. And then make another combination: name1 A1 B1 C1 D1 B1/A1 B1/C1 B1/D1 name2 A2 B2 C2 D2 B2/A2 B2/C2 B2/D2 and so on so on => divide

How to use javascript async/await on executing shell script

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-11 12:11:23
问题 So I have a server listening to RabbitMQ requests: console.log(' [*] Waiting for messages in %s. To exit press CTRL+C', q); channel.consume(q, async function reply(msg) { const mongodbUserId = msg.content.toString(); console.log(' [x] Received %s', mongodbUserId); await exec('./new_user_run_athena.sh ' + mongodbUserId, function( error, stdout, stderr ) { console.log('Running Athena...'); console.log('stdout: ' + stdout); console.log('stderr: ' + stderr); if (error !== null) { console.log(

How to use javascript async/await on executing shell script

人盡茶涼 提交于 2021-02-11 12:11:08
问题 So I have a server listening to RabbitMQ requests: console.log(' [*] Waiting for messages in %s. To exit press CTRL+C', q); channel.consume(q, async function reply(msg) { const mongodbUserId = msg.content.toString(); console.log(' [x] Received %s', mongodbUserId); await exec('./new_user_run_athena.sh ' + mongodbUserId, function( error, stdout, stderr ) { console.log('Running Athena...'); console.log('stdout: ' + stdout); console.log('stderr: ' + stderr); if (error !== null) { console.log(

Can't use requestAction from Shell in Cakephp 2.5

可紊 提交于 2021-02-11 07:59:10
问题 As stated, when I use in a shell : $this->requestAction('/sites/zaz/option1'); The action doesn't get triggered. To test this, I tried : public function zaz($option1 = null) { CakeLog::write('acces', 'action triggered'); return 'got it !'; } And the action isn't done and there is no log written whatsoever. All my other logs do work. So I tried : $this->requestAction('/sites/actionwhichdoesntexist/option1'); And I got an error stating that the action doesn't exist. I really need to use

Can't use requestAction from Shell in Cakephp 2.5

≯℡__Kan透↙ 提交于 2021-02-11 07:58:11
问题 As stated, when I use in a shell : $this->requestAction('/sites/zaz/option1'); The action doesn't get triggered. To test this, I tried : public function zaz($option1 = null) { CakeLog::write('acces', 'action triggered'); return 'got it !'; } And the action isn't done and there is no log written whatsoever. All my other logs do work. So I tried : $this->requestAction('/sites/actionwhichdoesntexist/option1'); And I got an error stating that the action doesn't exist. I really need to use

Bash - how to make arithmetic expansion in range braces?

一曲冷凌霜 提交于 2021-02-11 07:00:09
问题 I want to do this: for i in {1.."$((2**3))"}; do echo "$i"; done But that would output {1..8} , which I want to execute, not output. How to? 回答1: You can't do in like that in bash, brace expansion happens before variable does. A c-style for loop can be an alternative. for ((i = 1; i <= 2**3; i++)); do printf '%d ' "$i"; done ... Or if you really want to do the brace expansion use eval which is not advised to use but it is the only way... eval echo {1..$((2**3))} See the local bash manual for

Cygwin Path Error: Cannot find module 'C:\cygdrive\c\…'

帅比萌擦擦* 提交于 2021-02-11 06:54:37
问题 I am using Cygwin on Windows 7 and it was working as expected until I updated it a couple of days ago. Now when I try to run a makefile for my NodeJs app I get the errors about paths. In error stack I see all the paths have double reference to C drive: C:\cygdrive\c\... Update : Reproduced in Git bash, Windows command line and Cygwin shells. Any ideas how to fix this? 回答1: Make sure the C:\cygdrive\c path is a native, Windows-style symbolic link to just C:\ as that is the expected behavior of

How to pass backslashes argument to a script?

可紊 提交于 2021-02-10 23:28:58
问题 I just want to append an user input argument in a text file. I'm using the following command: echo "$2" >> "./db.txt" $2 is expected to user to set a path like: D:\Projects\MyProject . It writes to the file, but with no backslashes. The result is: D:ProjectsMyProject I can't find anywhere how to fix that. I've tried using -e or -E params(taken from here) but it doesn't seems to make difference in this case. 回答1: You have to escape backslashes in the shell: \\ , or put the string in quotes.

How to pass backslashes argument to a script?

跟風遠走 提交于 2021-02-10 23:26:25
问题 I just want to append an user input argument in a text file. I'm using the following command: echo "$2" >> "./db.txt" $2 is expected to user to set a path like: D:\Projects\MyProject . It writes to the file, but with no backslashes. The result is: D:ProjectsMyProject I can't find anywhere how to fix that. I've tried using -e or -E params(taken from here) but it doesn't seems to make difference in this case. 回答1: You have to escape backslashes in the shell: \\ , or put the string in quotes.

bash - Capture exit code from remote ssh command

六眼飞鱼酱① 提交于 2021-02-10 23:18:32
问题 I'm looking at capturing the exit status of a remote ssh command within a shell script I have a shell script as follows : function rSSH { local x echo "Running ssh command" x=$(ssh -o StrictHostKeyChecking=no -i $keyPair -o ProxyCommand="ssh -W %h:%p -i $keyPair user@$bastionIP 22" user@$IP "$cmd") x=$? echo "SSH status is : $x" if [ $x -eq 0 ];then echo "Success" else echo "Failure" exit 1 fi } rSSH exit 0 When I execute the above script as a background job with an invalid $bastionIP(