scripting

How to exit the interactive mode for yarn top command from within the bash script

 ̄綄美尐妖づ 提交于 2020-06-29 05:51:20
问题 I have a bash script which is on serverA. This script will ssh to serverB and runs yarn top command, pulls the metrics and put into the file(test.txt) on serverA. Below is the command which I am using: ssh -oStrictHostKeyChecking=no -i <key> username@hostname "yarn top" | head -5 | grep -w 'Applications' | awk '{print "Pending_apps" "\t" $7}' >> test.txt So here the problem is that after my script runs above command it goes into interactive mode and it only exits when I give Ctrl+C or quit

Compare multiple file name with the prefix of name in same directory

余生颓废 提交于 2020-06-29 05:07:41
问题 I have multiple .png and .json file in same directory . And I want to check where the files available in the directory are of same name or not like a.png & a.json, b.png & b.json 回答1: You may try this: import os _, _ ,files = os.walk('.').next() json = [f[:-5] for f in files if f.endswith('.json')] png = [f[:-4] for f in files if f.endswith('.png')] json_only = set(json) - set(png) png_only = set(png) - set(json) json_and_png = set(json) & set(png) ... etc... 回答2: from pathlib import Path

New-ExoPSSession error when using Connect-ExchangeOnline command in PowerShell

生来就可爱ヽ(ⅴ<●) 提交于 2020-06-29 05:05:49
问题 I ma trying to connect to Powershell using the Connect-ExchangeOnline command but I am getting the folloing error. Any ideas? New-ExoPSSession : . At C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\1.0.1\ExchangeOnlineManagement.psm1:445 char:30 + ... PSSession = New-ExoPSSession -ExchangeEnvironmentName $ExchangeEnviro ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [New-ExoPSSession], Exception + FullyQualifiedErrorId :

Run script only on click on button instead with open the sheets

本秂侑毒 提交于 2020-06-28 03:56:21
问题 Currently the following script runs with opening the Google Sheet table. I want to have that the script should only run with a click of a button. How can I do that? function getStatusCode(url){ var options = { 'muteHttpExceptions': true, 'followRedirects': false }; var url_trimmed = url.trim() || ""; var response = UrlFetchApp.fetch(url_trimmed, options); return response.getResponseCode(); } 回答1: Answer: Rather than using the =IFERROR * formula, you can make the function set the value for

Get data from one file to another (Bash) - Web Scraping

好久不见. 提交于 2020-06-27 16:56:11
问题 I am doing web scraping with bash . I have these URLs saved in a file called URL.txt . ?daypartId=1&catId=1 ?daypartId=1&catId=11 ?daypartId=1&catId=2 I want to pass these URL to an array in another file main.sh which would append in the base URL https://www.mcdelivery.com.pk/pk/browse/menu.html**(append here)** . I want to append all the URl in URL.txt file in the end of the base URL one by one. I have come up with the code to extract the URL from the URL.txt but it is unable to append it to

Best practice for exiting batch file? [closed]

会有一股神秘感。 提交于 2020-06-27 08:46:06
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 years ago . Improve this question For a batch file I want to check for different conditions and have a help message Which one is the best practice for exiting the batch file after displaying the message? if "%1"=="/?"( echo "help message" exit /b 0 ) [more code] or if "%1"=="/?"( echo

Easier way to parse 'query user' in PowerShell

孤街醉人 提交于 2020-06-25 00:11:08
问题 I currently have the following query in PowerShell: query user /server:$server Which returns output: USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME svc_chthost 2 Disc 1:05 8/16/2016 12:01 PM myusername rdp-tcp 3 Active . 8/29/2016 11:29 AM Currently, I'm using @(query user /server:$server).Count - 1 as a value to represent the number of users logged on (it's not pretty, I know). However now I would like to obtain information such as USERNAME , ID , and LOGON TIME to use in other parts of

How to get a variable to have the current dir path? [duplicate]

我只是一个虾纸丫 提交于 2020-06-22 03:46:08
问题 This question already has answers here : How do I set a variable to the output of a command in Bash? (14 answers) Closed 4 years ago . I have a really simple function in bash script that tells me the current directory. However it gives the error bash: =/home/users/abc: No such file or directory $currentdir is empty. Why is this happening? I also tried $currentdir=`pwd` and that didn't work too. This is a similar question Bash: current directory variable and I tried this but it didn't solve my

NSIS : NsProcess UnExpected Output

筅森魡賤 提交于 2020-06-18 13:07:50
问题 Newbee in NSIS, I was trying to implement the nsProcess plugin to check whether the current application is working or not ! I was successful in implementing the same in an example code, but when i tried implementing the same in my project i am getting an un expected output as shown in the Image message box below !! why am i getting this ?? please can anyone guide me. Thanks for the help in advance :) Project Snipet! !include "MUI2.nsh" ;!include "MUI.nsh" !include LogicLib.nsh !include

Combining two files into one in a specific format - Bash [closed]

痞子三分冷 提交于 2020-06-17 09:09:42
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 9 days ago . Improve this question I want to combine 3 files into 1 file in such a way format that it resembles (file1,file2) I have 2 files name.txt, price.txt Name.txt Cappuccino with Milk Chocolate Cookie Cappuccino with Double Chocolate Cookie Latte with Milk Chocolate Cookie Latte with Double Chocolate