Questions tagged [shell]

The term 'shell' typically refers to a category of text-based interactive command interpreters commonly found in Unix and Linux operating systems. If you have queries regarding shell scripting, it is advised to include a more precise tag such as 'bash', 'powershell' or 'ksh'. Without a specific tag, it is assumed that a portable (POSIX-compliant) solution should be used, but incorporating 'posix' or 'sh' instead is recommended.

Using Powershell to open a new terminal and execute a command in a bash session within WSL

Currently, I am in the process of creating a Powershell script to expedite setting up my development environment. My goal is to have multiple instances of WSL programs running on bash terminals. My objectives from within Powershell are as follows: Open a ...

Advantages of opting for npm instead of a shell program like Bash

Recently, I've delved into using npm (https://www.npmjs.com) and it's impressive how versatile it is as a build tool. However, as I explored further, I began to question its uniqueness. When you think about it, npm operates similar to a shell program (suc ...

Utilizing Airflow's web API to generate a JSON variable

Attempting to set up a variable with a JSON value in Airflow using the web API. Here is my script: curl -X POST "${AIRFLOW_URL}/api/v1/variables" -H "Content-Type: application/json" --user "${AIRFLOW_USERNAME}:${AIRFLOW_PASSWORD}" ...

Ways to eliminate unnecessary quotation marks surrounding a string in a JSON file using a shell script

I need help removing extra quotation marks from the following JSON data: {""id"":""1"", ""name"":""john"",""address"":"",""timestamp"":""2018/01/01 12:43:42 -700"",""dept"":""} To address this issue, I have been using the sed command: sed -i -e 's/ ...

Encountering an SSH issue while attempting to deploy to Digital Ocean using Gitlab's CI/CD functionality

Hey there, I've been attempting to deploy to Digital Ocean using a Gitlab CI/CD pipeline. However, every time I run the pipeline, I encounter the following error message: "chmod: /root/.ssh/id_rsa: No such file or directory $ chmod og= ~/.ssh/id_rsa C ...

What is the best way to incorporate the "child_process" node module into an Angular application?

Trying to execute a shell script in my Angular application has been quite the challenge. I came across the "child process" node library that might be able to help me with this task. However, every attempt to import the library led me to the error message: ...

displaying results on a webpage

Is there a solution for displaying a Linux shell output on a web page that allows for continuous updating without needing to start and stop the process each time? I require a network analyzer tool based on a shell that can run continuously, similar to comm ...

Retrieve keys only in a concise list using JQ

I am working with a Pipfile.lock JSON file that requires parsing using the jq tool. The format of the file is as follows: { //... "default": { "value1": { // numerous nested properties with values ...

Utilizing the sub() function in jq to dynamically modify JSON values based on specified conditions

I'm in need of modifying certain values within JSON data and integrating it into an existing shell script. My aim is to utilize jq for this task, specifically the "sub()" function to trim a portion of a string value. Executing the following command line: ...

Error in executing Python script within Node.js due to syntax issues

When I attempt to run a Python script using the python-shell package in Node.js, I encounter a SyntaxError: invalid syntax. Node.js code const options = { mode: 'text', pythonPath: '/usr/bin/python3', scriptPath: __dirname + '/script', }; var ...

Removing identical sections that have the same starting and ending points using Python or Shell

I'm just starting out with Python and I have a text file that contains some definitions like the following: .subckt inv a z mp z a vdd vdd pch mn z a gnd gnd nch .ends .subckt pg in out clk clkb mp in clkb out vdd pch mn in clk out gnd nch .ends .s ...

Using JQ to structure logs in shell scripting

I've been looking to save some shell scripts into a file for collection by an agent like Fluentbit and sending them off to Cloudwatch and Datadog. I came across this example online that works effectively with the use of jq. __timestamp(){ date "+%Y ...

Guide on programmatically setting up nvm and utilizing npm

Hey there! I've been working on some scripts to customize my shell environment, and everything is going great except for nvm. Here's a snippet from my script: #!/bin/zsh set -Eeuo pipefail echo 'Installing nvm' touch $HOME/.zshrc curl -o- https://raw.git ...

Executing a Python script through Node.js and storing the output as a file

Despite being able to successfully run a python script, I am facing challenges when it comes to saving a file using the script. While running the python script directly from the terminal yields positive results, spawning a node process seems to fail withou ...

Edit a specific portion of a document while disregarding the rest of the content

I am seeking to update a specific portion of a file with the following structure: { "Section_A": { "ws/abc-Location01": 24, "ws/abc-Location02": 67, "ws/abc-Location03: 101, }, "Section_B": { "ws/abc-Location01": 33, "ws/ab ...

Automatically generate an .au3 script using my C# code

I am faced with a challenge of automatically compiling an .Au3 script code and then running it. The script (au3 file) is updated automatically, but in order for the updates to take effect when I run the script, it needs to be compiled first. While there ar ...

Access to '/usr/lib/node_modules' has been denied due to error EACCES

Struggling to set up typescript using the command npm install -g typescript, I encountered the following error message: npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules' npm ERR! at Error (native) npm ERR! { Error: ...

Creating an Automated Backup Solution for Your Website using Bash/Shell Scripting

I am completely new to shell scripting and have been scouring the internet for guidance on how to create a backup script for my website. Unfortunately, I haven't been able to find anything that I can understand. I have a Synology Diskstation server a ...

Running a shell script without double quotes can lead to errors in Ruby code

After creating some JSON data and passing it to another Python script, I realized that the double quotes around the JSON elements are missing. Here is a snippet of my code: json = @report.resultReportToJSON(result_type, result, unit) puts "#{json}" `"pyth ...

Managing multiple NodeJS applications simultaneously

Is it feasible to execute 3 or more nodeJS Applications using a single command through a shell script? The concept involves having a shell script that navigates into the app directories and runs the npm command. Using the npm package concurrently is not ...

Leveraging the power of bash to execute a python script

I wrote a python script that takes a .txt file as input and produces another .txt file as output. My goal is to create a bash script that I can simply click on from my desktop to run the python script. This is what I have done so far: #!/bin/bash cd /Des ...

Guide on utilizing linux curl for authentication and accessing data post login

I am in possession of a Stiebel Eltron heat pump device for my home and I am seeking to utilize Linux shell curl (not php) to login via POST request and retrieve data through a GET request once logged in Here is the structure of my curl login POST call (I ...

unable to run multiple commands simultaneously in shell script using terminal

I'm attempting to run the following commands in parallel using &: ENV=prod npm run SettingsSuite -- --runid Prod_E2E_$BUILD_NUMBER --APPNAME Prod_E2E --squad ops --track coreServices; echo $? >> "$log_file" & ENV=prod npm run InventorySuite -- ...

Secure shell access to Amazon EC2 using PHP

When I try to run a PHP script connecting from my local Ubuntu Linux machine to an EC2 instance using SSH, it executes fine when run from the terminal and writes the tailed entries in a file. However, when I try to run it from a browser, I encounter the fo ...

Leverage environment variables within SFTP paths when using Paramiko

Currently, I am executing a script on my server and attempting to retrieve some files from my Firewall. However, when I use an environment variable (signified by the $ symbol) to reference the file, I encounter a "file not found" error. Surprisingly, I hav ...

What steps can I take to protect my website from malicious shells and malware uploads?

I run a website for sharing images and videos, but I'm concerned about its security. I've noticed that anyone can upload harmful shells or malware instead of legitimate content. I'm curious how YouTube and Facebook are able to prevent such vulnerabilitie ...

Customize Nova.conf in Devstack by configuring it in the local.conf file

I am currently utilizing Devstack in my development setup. When it comes to adding specific configuration settings in the nova.conf file, one can employ the following code snippet: [[post-config|$NOVA_CONF]] [DEFAULT] notification_driver=messagingv2 noti ...

Utilizing the Linux grep command to extract key values from a JSON file

My dilemma lies in handling the JSON output I have, which contains a list of objects stored within a variable (I hope I expressed that correctly). I've tried executing a curl command to obtain the output, but unfortunately, I'm unable to share i ...

What is the best way to use cURL in a shell script to send a request with custom

When attempting to run a CURL statement, I successfully received the desired response: curl -s -POST --header 'Content-Type: application/json' 'http://www.dummy.com/projectname/page_relevance' -d '{"query": "q_string", "results": [{"abstract": "abs_string ...

Passing parameters from PHP to a shell script

Can parameters be passed from php to a shell script? For example: <?php $var = "testfolder"; shell_exec('sh /path/test.sh $var'); ?> Shell script (test.sh): sudo mkdir $1 /path/ I want the value in php $var to be passed to the shell ...

A guide on utilizing a Python script to update and upgrade a Linux system

Looking to enhance a virtual machine through the console, I am new to Python and have experience with shell but wish to use a Python script for this task. I know about using subprocess or os.system commands, but find it challenging to convert the shell sc ...

How to merge multiple JSON files in a directory using jq

I have a collection of approximately 100 JSON files, each containing an array with 100 simple records that I want to merge into a single file to use as static data in an application. This will help me avoid making multiple API calls to retrieve small piece ...

Script using PHP to remotely connect to a Linux server and run a Bash script

Currently, I am facing a challenge where I need to execute shell commands on our remote servers using PHP. The main goal is to install scripts through bash by having PHP execute these scripts on the server remotely. However, I have encountered an issue wh ...

What is the method to execute Popen using a custom shell?

I have been developing a tool that is designed to execute a series of commands. These commands are written as if they were being entered into a terminal or console. In order to achieve this, I have utilized Popen() with the parameter shell=True to replica ...

Put the title tag within a script in the shell

Within an HTML snippet, I currently have a <title> tag that I need to change on a monthly basis when generating reports. While I can manually update it each month, I am looking for a way to automate this process so the title reflects the relevant rep ...

Error in Python IDLE while executing openpyxl script

I have encountered an issue while trying to use openpyxl from a script. When I use openpyxl from an IDLE shell, everything works smoothly: Python 2.7.9 |Anaconda 2.2.0 (32-bit)| (default, Dec 18 2014, 17:00:07) [MSC v.1500 32 bit (Intel)] on win32 Typ ...

Creating environment variables and making changes to a JSON file with the Power Shell Script Plugin in Jenkins: A step-by-step guide

The JSON file is located at %Workspace%\solution\config\appsettings.json { "appName": "Test", "appId": "1", "env" : "Test", "url" : "https://url.com", "client_id": "", "client_secret": "", "QAEmail" : "<a href="/cdn-cgi/l/email-protecti ...

Encountering an error with the node module timestampnotes: 'command not recognized'

I am encountering an issue while trying to utilize a npm package called timestamp notes. After executing the following commands: $npm install timestampnotes $timestamp I receive the error message: timestamp:126: command not found: slk Subsequently, I ...

Basic HTML and JavaScript shell game concept

After spending several days working on this project, I am struggling to understand why the winning or losing message is not being displayed. The project involves a simple shell game created using HTML, JavaScript, and CSS. I have tried reworking the JavaSc ...

Running Python code from a shell script

Is there a way to incorporate Python code directly into a shell script without relying on an external file? I've done extensive research, but I couldn't find a clear answer. Most solutions involve running an external Python script from the shell ...

Utilize shell scripting on Linux to parse JSON data

Similar Question: Parsing JSON using Sed and Awk I have an example of a JSON string provided below. I am interested in extracting the value of the "uptime" field to use as a variable in a shell script. How can I achieve this? { "serverStatus" : { " ...

What is the best way to display several values on a single line using `jq`?

After parsing through my json data, I've come across the following structure: { "Items": [ { "id": { "S": "c921e4eb-5958-424a-ae3a-b9cada0d9481" }, &quo ...

Encountering a shell script parsing problem: Could it be an unexpected INVALID_CHARACTER due to Windows cmd shell quoting

What am I trying to accomplish? I have a JSON file called sonar-report.json. My goal is to iterate through the sonar-report.json in a shell script and extract values from the JSON file. To achieve this, I am using jq as my JSON parser (). Below is the cod ...

Attempting to have the command "npm run dev" generate two separate shell instances

For my nuxt project, I decided to use json-server as the local server. My goal is to automate the process of launching the server and running the project on a separate shell instance by using the command "npm run dev". After some exploration, this is the ...

Is it possible for Python to perform in a similar manner in a bash script?

Is there a way for Python to create paths with multiple sub-paths using shortcut syntax similar to this? vars=project/{DEBIAN,usr/{bin,usr/{applications,icons,share}},computer} ...

What is the process for modifying the output format of npm ls?

My client is requesting the dependencies of our projects, including the library name and github/NPM URL. Currently, I am using 'npm ll' command to retrieve this information for each project, but the output is in a tree structure. Is there a way to convert ...

What is the best way to get a server to continuously request a JSON file at regular intervals?

I am currently dealing with updating and displaying real-time information from a third-party JSON file that is approximately 1MB in size. The challenge lies in the fact that this JSON file updates constantly, and my access key may be revoked if users direc ...

What steps should I follow to activate the Terminal plugin on Pycharm Edu version 3.5.1?

On a recent visit to JetBrains, the recommendation was to enable the Terminal plugin in Pycharm. However, I am unable to locate it anywhere within my application. This has become quite problematic as I urgently need access to the Terminal for an ongoing ...

Can a script command be used to trigger a particular PHP function in a PHP file via a bash script?

The title of this question is pretty self-explanatory, but I'll provide some more details. There's a PHP file named hello-world.php and a bash script named testBash.sh in my setup. Inside hello-world.php, there are two methods: helloWorld() and ...

The mongoose query appears to be functional in the mongo shell but is experiencing difficulties within a Node.js

Trying to retrieve a list of todos based on the 'userId' associated with each one is proving difficult. The code below does not return any rows: DB.TodoTable.find({ "userId" : ObjectId("54c12f5f3620c07019e6b144") }, function(err, todos) { if (err) ret ...

Tips on restarting a remote dedicated server using a PHP script or a PHP shell client

My current project involves finding a method to remotely reboot a dedicated server using php. During my search on various platforms, I came across information about Python shell client. Is there an equivalent in php? Would it be possible to utilize php fo ...

How can I pass command line variables into an npm script?

I am facing an issue where I am attempting to pass a command line option (which is not stored in version control) to my main script index.js. This script performs specific actions based on a designated S3 bucket. Here is the relevant section from my packa ...

Python's absence has been noted, thus rendering the script unable to be executed

Today, I encountered an issue while trying to run a Python script: python ./helloworld.py -bash: python: command not found Despite having Python installed on my computer: whereis python python: /usr/bin/python3.6 /usr/bin/python3.6m /usr/lib/python3.6 / ...

Running an rsync shell command through a PHP script in a web browser

At first, our objective is to transfer modifications from one system to another using a shell script named synchfolders.sh. The content of the file is as follows: rsync -av --delete -e 'sshpass -p Wordpress@123 ssh -p 22' <a href="/cdn-cgi/l/ ...

Running multiple npm tasks concurrently using a ".sh" file in Windows: a step-by-step guide

Brand new to ".sh" right now when faced with this question. I am not even certain what ".sh" refers to - Shell, Powershell, Bourne shell, etc. Currently, I am operating from a Windows OS. The goal of this question is: Change directories Run the npm scrip ...

Web user unable to execute binary file

I have encountered an issue with a php script that generates a shell script file which is executed as the user www-data. Most of the commands in the script run without any problems, but the last command involving a binary file fails to execute when the scr ...

Retrieve the value from the initial element of the JSON array received from the GitAPI response within a shell script

I'm trying to retrieve the browser download URL for the latest release from a specific Git repository using the GitHub API. Sample command: curl -i https://api.github.com/repos/$owner/$repo/releases The response is in the form of a JSON array. Assuming ...

What is the reason for the failure of line-buffered piping between this Python script and this socat script?

My Python script serves to convert user IRC commands such as "/nick hello" or "/quit" into IRC protocol messages efficiently. It performs this conversion by taking input line by line from stdin and then producing the translated message on stdout. I also ha ...

Server-side script for communicating with client-side JavaScript applications

Currently utilizing a JavaScript library that uses a JSON file to display content on the screen in an interactive manner. (::Using D3JS Library) While working with clients, it is easy to delete, edit, and create nodes which are then updated in the JSON fi ...

What are the steps to generating and sharing 'npm create' scripts?

I am looking to develop and release a script on npm that functions similarly to: npm create qwik@latest or yarn create next-app --typescript However, I am unsure where to begin. Despite searching extensively online, I have not been able to find any helpf ...

Manipulate Json in jq with Shell Script

I am currently working on a shell script that updates specific values within a JSON array, which is stored in a separate file. The basic logic behind this script involves setting an environment variable called URL, pinging that URL, and then modifying the ...

embed the JSON data from one file into the vacant array within a different file's JSON structure

My goal is to include this block of code from the devices_format.json file: { "devices": [ { "name": "new_elsys", "objects": [ { "name": "ServerRoomTemp", "datapoint_type": "measurement", "coder_fiel ...

Extract and display the custom file's output using shell_exec function in PHP

Is there a way to view the output of a shell script in a format similar to PuTTy or gnome-terminal using a php script? I attempted to use shell_exec with the following invocation: $output = shell_exec('echo "return value: ";foo=$(nameOfFileToExecute) ...

Is there a way to launch a shell using a Python command?

When I enter the following command into bash, it opens a new shell and launches nano: gnome-terminal -e "bash -c 'nano test; bash'" I attempted to replicate this in my Python code using subprocess: import subprocess command = "gnome-terminal" ...