Questions tagged [sh]

1

votes
3

answer
13k

Views

unexpected EOF while looking for matching `'' while using sed

Yes this question has been asked many times, and in the answer it is said to us \ escape character before the single quote. In the below code it isn't working: LIST='(96634,IV14075295,TR14075685')' LIST=`echo $LIST | sed 's/,/AAA/g' ` echo $LIST # Output: (96634AAAIV14075295AAAT...
Bharat
1

votes
3

answer
334

Views

How to remove numbering from “lynx --dump -listonly”

$ lynx --dump -listonly index.html Example result: References Visible links 1. http://lynx.invisible-island.net/ 2. http://lynx.invisible-island.net/lynx.html 3. http://lynx.invisible-island.net/current/index.html What I want to do is remove the 1. 2. and 3. 'References' and 'Visible Links' text inc...
1

votes
2

answer
4.1k

Views

Dockerfile: how to set env variable from file contents

I want to set an environment variable in my Dockerfile. I've got a .env file that looks like this: FOO=bar. Inside my Dockerfile, I've got a command that parses the contents of that file and assigns it to FOO. RUN 'export FOO=$(echo '$(cut -d'=' -f2
Ben Downey
1

votes
2

answer
60

Views

Most Efficient way to find pairs between 2 arrays in bash

I have 2 large arrays with hash values stored in them. I'm trying to find the best way to verify all of the hash values in array_a are also found in array_b. The best I've got so far is Import the Hash files into an array Sort each array For loop through array_a Inside of array_a's for loop, do anot...
Don Richards
1

votes
1

answer
16

Views

How to execute .sh file in ruby on rails

I'm trying to execute .sh file in rails index action. I try exec'sh app/controllers/myscript.sh' it's execute it in terminal then stop the server! I don't know why. And I try output = system'sh app/controllers/myscript.sh' it's return true in the browser not what is in the .sh file Thanks in advanc...
yuna
1

votes
1

answer
66

Views

sh script to replace text in multiple files

I am trying to replace every occurrence in a .prm file of the string '/net/origin/devdata1/slin' with '/tools/common/test/HATS' in over a hundred files using sed. I think I am having trouble with the proper syntax for a for loop that loops through different files in a directory(/home/AutoTest), and...
dhboots
1

votes
1

answer
80

Views

Multiuser screen session from a shell script

I've looked up every tutorial i've found but none of them really answer my question. I'm looking for a way to make a script which will : Create a screen Launch a 'nodejs file.js' command in it Distach Make the screen accessible to every user from the group 'devs' For now here is the shell script I w...
Rackover
1

votes
0

answer
118

Views

AppIcon overlay is not working in Xcode 9.2

Recently I was searching something great for my app, and I found that I can add an overlay to AppIcon for different Configuration of the project. But it is not working in Xcode 9.2 with iOS 11.2.2. Here is what Tested. Using Amaro I can get an overlay of version and build with the configuration in X...
Mrugesh Tank
1

votes
1

answer
43

Views

Git cli not terminating on pull --rebase

I am running Git v2.15.1.2 on a 64-bit machine. Whenever I try executing $ git pull -r to pull the latest update of my GitHub repo, this will happen: 1) The pull is successful, but it never returns to the line where I can type. 2) No matter how long I wait, it just bails out into a sh.exe.stackdump...
TheV0rtex
1

votes
1

answer
340

Views

Awk not printing the whole line

I am executing the following script using awk which prints the columns of a file in a different order. #!/bin/sh cat test.txt | awk '{ if ($3 != '') {print $3 ' ' $1 ' ' $2} else if (($3 == '') && ($2 != '')) {print $2 ' ' $1 } }' > test_proc.txt My expectation of output from: print $3 ' ' $...
valar_m
1

votes
2

answer
62

Views

how to read a variable from text file and assign that value to other variable using shell script

I have a huge text file which consists of various variables and other data. I have to search for a string 'User_Name' and get its value(name, after = ). name after = is always 'quoted' I have one shell script which uses this text file data. At one point(line) in code it has to take the User_Name val...
Kumar
1

votes
0

answer
22

Views

Unix Script to convert particular pattern of string to another

Input file is: a.txt a PIC x(1). FILLER PIC X(2). c PIC s9(9)v99 COMP-3. FILLER PIC x(1). d PIC s9(7)v999 COMP-3. Output (After executing test.sh (sh test.sh a.txt), tmp_a.txt file created.), tmp_a.txt: a char(1). FILLER_1 char(2). c PIC s9(9)v99 COMP-3. FILLER_2 char(1). d PIC s9(7)v999 COMP-3. Exp...
Viki
1

votes
1

answer
47

Views

How to find bash script name from pid?

I'm using SUNOS. First I run that command to find top cpu using proccesses. ps -eo pmem,pcpu,pid,args | sort -rnk 2 Then its the output 0.0 4.2 19105 bash 19105 is 'process id' and, 'bash' is args. I just saw bash in args section. How can I find which bash script is working? I tried pwdx command b...
Süleyman Orhan
1

votes
0

answer
42

Views

Error protocol and QXcbConnection when I run a game after update to Debian Testing Buster

I was playing my game normally before the update, I was at Debian 9.3 Stretch. After update I try to run the game with the same command. bash start-tibia.sh And Output this: No protocol specified QXcbConnection: Could not connect to display :0 Aborted I don't know why this happening. My system: ent...
Orlando Cartagena
1

votes
1

answer
588

Views

arping Error { bind: Cannot assign requested address } when trying to run it remotely

Local Server : Lets say local1 Remote Server: Lets say remote1 I have the following shell script in local1 server; #!/bin/sh comm1=`arping -c 3 -s 192.168.xxx.xx 192.168.yyy.yy | grep 'reply from 192.168.yyy.yy' | awk '{print $2,$3,$4}' | tail -1 | awk '{print $3}'` comm2='192.168.yyy.yy' if [[ '$co...
Muthu
1

votes
1

answer
349

Views

Shell script to modify variable with file name of multiple files in same directory

I have a multiple files in a directory, e.g.: a01.txt a02.txt a03.txt etc... Line 3 of all text files in the directory is as follows: consumer[location].userid= constant I want to replace the word 'location' with the respective filename without extension in the third line of each file eg: as consu...
7pkbea
1

votes
0

answer
81

Views

Trying to use ProcessBuilder in Java to give input to shell script during execution

I am trying to execute a shell script that takes input with Java. Here is my code so far... OutputStreamWriter output; Process p = new ProcessBuilder(new String[]{'sh', '-c', '/data1/Abhishek/hello.sh'}).start(); output = new OutputStreamWriter(p.getOutputStream()); String line = ''; String text = '...
1

votes
0

answer
236

Views

How to get around multidimensional arrays in BASH?

I am using bash to create program that: Takes the user input for a person's name and their quarterly sales figure and puts them into separate arrays. The user is then given an option to sort either alphabetically by name or numerically by their sales figure. I need a way of making sure that both...
D'Arcy
1

votes
2

answer
938

Views

Open terminal, run python script and keep it open for results?

How to get an sh script for starting a new terminal, execute a python script and keep it running? The python script is supposed to run continuously in a perpetual loop, spitting out results as they pop in. Whenever trying with sh-script for gnome-terminal just getting: child process exited normally...
Joey de La Moey
1

votes
0

answer
330

Views

EMR bootstrap installing python modules - bootstrap action 1 returned a non-zero return code

I am trying to install python modules through the EMR Console bootstrap actions by following these steps: Uploading a file to: s3://mybucket/bootstrap/install_python_modules.sh containing the following script: #!/bin/sh set -e -x sudo apt-get install python-setuptools sudo easy_install pip sudo pip...
Simonidas
1

votes
1

answer
32

Views

How can we identify the line number in a file matching a particular keyword or a string in terminal?

For example, let's say: I have a file text.txt, in which I have the following lines of code: void func() { ordinaryStuff(); extraordinaryStuff(); //a comment whoo! } Now with a terminal command, how can i identify on which line i have written ordinaryStuff(); extraordinaryStuff(); or added a comme...
Pranshu
1

votes
1

answer
1.3k

Views

/bin/sh: my_custom command not found inside Docker container

The context is the following: I need to run ffmpeg in a AWS Lambda service that is deployed and build using Docker. Since the docker image we use is not debian and does not includes ffmpeg, I created a binary file with the command and added it to the project files. Then, inside the Dockerfile, I cre...
ntonnelier
1

votes
0

answer
52

Views

How to pass arrays with spaces as function arguments in Bash [duplicate]

This question already has an answer here: How do I pass on script arguments that contain quotes/spaces? 3 answers Bash array with spaces in elements 7 answers I have the following script: brews=( java8 archey aws-shell 'bash-snippets --without-all-tools --with-weather' cheat coreutils dfc findutil...
pathikrit
1

votes
2

answer
157

Views

Trim table of text and store values as variables

I am trying to write a script that can be run on my FreeNas (FreeBSD) box, that connects to an ESXi host via SSH and gracefully shuts down VMs. What I need to run for a list of VM IDs is: vim-cmd vmsvc/power.shutdown VMID Am after some assistance in filtering the output of the commands used to retri...
Eds
1

votes
0

answer
185

Views

How do I set up an rc.d script to start Plex Media Server in FreeBSD?

My LG TV stop working with my older version of Plex 1.3 so I was forced to update to Plex 1.13 I'm running my version of Plex on Nas4Free 0.9 in a jail. I was able to download and it runs but will not auto start. For some reason the plexmediaserver script in /etc/local/rc.d fails. Has anyone else ou...
Showcaselfloyd
1

votes
0

answer
119

Views

if-else on arguments in npm run script

I would like to call different other scripts, depending on whether a paramter is given or not: 'paramtest': 'if [ -z $1 ]; then echo Foo $1; else echo Bar; fi', npm run paramtest should give 'Bar'. npm run paramtest -- whatever should give 'Foo whatever'. However in practice I only get: (The paramet...
Frank Nocke
1

votes
0

answer
329

Views

Shell scrilpt : binary operator expected

I have a bug in my shell script, I know it is at the while loop but I cant see it, I already check spaces. I also try to use test instead of parenthesis but I have the same error If I comment the while loop my code works line 45: [: -1e: binary operator expected my code is #!/bin/sh # pe request...
Dulce Camacho
1

votes
1

answer
43

Views

Convert repeated code into a loop

I have a router running DD-WRT that has a start up script used to wake my computer on LAN requests on certain ports. I found this shell script here and changed it to allow for wake on multiple ports. I tried doing a for loop so I wouldn't have to repeat any code, but that didn't work. That only thin...
MattR
1

votes
0

answer
27

Views

Issue with curl -F on Android

I am creating an app with Tasker, and am using Run Shell with curl to make a POST to my server However I cannot seem to make the request: curl -F 'a=a' https://google.com --> Error: 43 (Internal Error) This occurs on the -F, --form, and --form-string parameters curl --version 7.50.1-DEV (Android 7.0...
Skyler Soss
1

votes
0

answer
153

Views

Is there a shell script equivalent of prctl(PR_SET_PDEATHSIG, SIGKILL); for handling zombie children?

So in C and C++ I've been using prctl(PR_SET_PDEATHSIG, SIGKILL); and it works great. When I spawn child processes in shell scripts I use something like this: pid=$! trap 'kill $pid' SIGHUP SIGINT SIGTERM wait Which works in all cases except when the shell script gets a SIGKILL (which it can't catc...
mpr
1

votes
2

answer
36

Views

Linux .sh auto set local variables empty when echo

./run.sh: 1. cp=warmonger-1.0.0.jar 2. cmmd='java -server -D64 -Xms200m -Xmx200m -Dlog4j.configurationFile=$WARMONGER_HOME/etc/log4j2.xml -classpath $cp warmonger.agent.WarmongerAgentApp' 3. echo $cmmd execute results: dataq.agent.DataqAgentApp -Xmx200m -Dlog4j.configurationFile=/warmonger/etc/log...
Broderick
1

votes
0

answer
65

Views

how to import variables from the python script to slurm job script

I am trying to run a CFD simulation in HPC and I want to import the Wall Clock Time, from Python. Can anyone suggest me best way to go. Python Code # Python variables walltime = 10000 #sec Slurm File # =========================================== # Code to import from python. # ======================...
1

votes
1

answer
40

Views

raspberry pi hcitool set ad packets import from csv file

There is a well known blog post going around on how to set a usb bluetooth 4 dongle to be an iBeacon. It boils down to this magical command: sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61 12 34 56 00 C8 00 Now I want to edit E2 0A 3...
偉健 WanChart
1

votes
1

answer
34

Views

How to use pv command in a backup

I am doing a backup dd if=/dev/vda1 | lzop > /etc/BACKUP/im.lzo and I want to see the progress bar using the command pv but I don't know what the correct syntax for this is. I have tried: pv dd if=/dev/vda1 | lzop > /etc/BACKUP/im.lzo dd if=/dev/vda1 | lzop > pv /etc/BACKUP/im.lzo dd if=/dev/vda1 |...
Gonz
1

votes
2

answer
133

Views

Get selected extension file count and size in a directory

How to print only .TXT or .csv files and their human-readable size in a folder Example: file type | total count | total size .TXT 30 40MB What I've done so far: $ find . -type f -name '*.TXT|csv' | wc -l
Tes Cix
1

votes
1

answer
125

Views

Splitting csv-file with awk on column

I have a big csv-file that I want to split in smaller csv-file, I have a somewhat working solution: awk -F\t '{print > $2}' big.csv But my problem is that I want the files to have .csv at the end, not just the column as it is now. Any ideas? big.csv 'a name' 'type' 'some more info' 'and a bit mor...
Elmseld
1

votes
1

answer
209

Views

Convert Multiple Audio Tracks of Multiple Files FFmpeg

I'm using a script to convert all video files in a folder. These files have multiple audio tracks and I want the converted files to have each audio track as well. I've tried both -c copy and -c:a mp3 and neither worked for me. Any ideas how I can modify this to copy all audio tracks? #!/bin/sh for i...
Raviga
1

votes
0

answer
79

Views

Bash - Read HTML & find div based on two different variables

I am trying to get information from a div based on a date that I am holding as a variable, then I am trying to filter the returned results based on another variable to narrow down the results list to a single match in order to extract the URL. Example of the HTML of the page, this will have another...
Sukh
1

votes
0

answer
155

Views

udev rule successfully grabbing device, but failing at creating symlink

I am trying to create a udev rule for a specific device, more specifically a usb snes controller. The device information is as follows: looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/0003:0583:2060.0006/hidraw/hidraw0': KERNEL=='hidraw0' SUBSYSTEM=='hidraw' DRIVER=='' looking a...
st0ck
1

votes
0

answer
38

Views

How to pass variables set in sh script to subsequent Jenkins Pipeline Steps

I have a jenkins pipeline file where i need to call an sh file node { stage('Stage1') { checkout scm sh ''' echo 'Invoking the sh script' valueNeedstobepassed = 'test' ''' } stage ('stage2') { Need to refer the 'valueNeedstobepassed' varaible in my pipleline step } } I am not able to refer the var...
ASChakkalakal

View additional questions