Stack Exchange Network

Stack Exchange network consists of 175 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 [scripting]

A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.

0
votes
0answers
10 views

shell script to copy file from one server to another based on argument

This is a shell script to copy file from one server to another using sftp. When we are executing shell script we are passing one parameter as a argument and it must use this parameter to identify the ...
-1
votes
0answers
19 views

#!/bin/bash - how to code?

I need to make changes to my script. my script is: sum=0 for numberr in "$@"; do echo "$numberr" | grep '[^0-9+-] if [ $? -eq 0 ]; then echo "Sorry '$numberr' is not ...
-3
votes
0answers
30 views

Compare columns and find the difference from a table dynamically

I have a table with 3 columns,first column is some parameter and remaining 3 are last 1 week count of those parameter and has content similar like below. first row is table columns from oracle. I have ...
0
votes
0answers
43 views

Completely Clear command prompt through bash

I am actually making a menu for my official server. I made it through bash scripting on AIX. The problem i am facing is that when script is running, user can scroll up and see history of all commands ...
0
votes
1answer
60 views

How to detect if the computer is idle? [on hold]

I'm using Linux Mint, and I run the below service with system start up to0 take automatically screenshots, but I need it to stop taking screenshots if the computer is idle, and run again when it is ...
0
votes
0answers
13 views

sqlplus script how to using array parameters [on hold]

I have a file "outputCSV.sql", using sqlplus to call this file sql. But have parameters (&1, &2, &3, &4, &5), I want to loop list parameters, but I cannot doing. outputCSV.sql ----...
-1
votes
0answers
15 views

Script to shutdown ExpressVPN through the Terminal on computer shutdown

I need a script to shutdown ExpressVPN through the Terminal on Shutdown. Previously, I created a startup script that I cobbled together from scripts that people had posted on various websites. The ...
0
votes
0answers
42 views

Number of characters in test.txt is 20 Number of words in test.txt is 3 Number of lines in test.txt is 3 [on hold]

Write a shell script which displays the total number of words, characters, lines in a file. Assume the file name is given as command line argument. file=$1 if [ $# -ne 1 ] then echo "$0 fileName" ...
-1
votes
0answers
19 views

How to execute script on remote linux machines [on hold]

I am trying to get df -h output from different Gnu/Linux hosts, and get output to my local host, while all remote hosts have different root passwords.
3
votes
3answers
35 views

reliable scripting way of obtaining UUID of boot partition

I want to script a somewhat automated method for editing /etc/default/grub and appending fips=1 boot=UUID=???? to GRUB_CMDLINE_LINUX= coincidentally /etc/fstab contains UUID=12345blabla /boot xfs ...
2
votes
0answers
39 views

Using killall with -u and -o options

I wanted to confirm some details with the killall -o option. I tested it on some ssh connections I created under the user rick. First I printed a list of all of ricks ssh connections along with the ...
0
votes
1answer
83 views

difference between echo ($x) and a=“($x)”; echo $a

When I execute the following in terminal: x=1 a=($x) echo $a #output: 1 echo ($x) #output: -bash: syntax error near unexpected token `$x' Why are above outputs different? Also why are the ...
0
votes
1answer
16 views

Sending email via mutt as root on RaspberryPi

I have an application that needs to run as root for access to hardware on the Raspberry Pi. In this application I need to send emails with attachments containing data. I am able to write a bash ...
-1
votes
0answers
25 views

How to combine multiple commands into one script (awk & sed)

I have an output file test_mini [...srv01]$ cat test_mini tobias@(Whatever_LTM1)(cfg-sync Changes Pending)(Active)(/Common)(tmos)# cd ..;list /ltm virtual recursive destination^M Display all 96 ...
7
votes
2answers
79 views

Inverting an associative array

Let's say I have an associative array in bash, declare -A hash hash=( ["foo"]=aa ["bar"]=bb ["baz"]=aa ["quux"]=bb ["wibble"]=cc ["wobble"]=aa ) where both keys and values ...
-5
votes
2answers
58 views

Bash - How to find the longest txt file in a folder? [closed]

I need to write a script which finds the longest txt file in a folder. I literally have no idea how to do it
-2
votes
2answers
19 views

how to remove all characters after and including “?” in filename?

I have a large amount of files that were downloaded and ended up having what looks like authentication parameters added to the filename which I would like to remove. Examples: file1.doc?...
1
vote
1answer
25 views

turn awk command into an awk script (multiple F)

I have a working command awk -F '[)#/(:]' 'BEGIN { fw="";dev=""} {if ($0~/sh failover/) fw=$1 ; if (($0~/This host/)||($0~/Other host/)) dev=$2; if ($0~/\)\:/) {print $2,$1,fw, dev} }' OFS="|" ...
2
votes
2answers
69 views

Killing a process and diffing its result

I've been trying to write a simple bash script, but I cannot get it to work. I want to: Start a program, feeding it input from a text file (./prog < input1.txt) Wait a short amount of time and ...
0
votes
0answers
16 views

Shutdown PC after remmina connection closed

I'd like my PC to shutdown straight after I close my remmina remote connection. I searched for solutions but remmina itself shows abnormal behavior. someprogram && sudo shutdown -h 0 Running ...
1
vote
1answer
28 views

Taking input in a script and making sure there's only one parameter

I'm currently working on an assignment where I have a script that is basically just getting to learn using grep with different regex's. I have the script written except for the first part where I am ...
1
vote
1answer
88 views

Passing arguments from one script to another

Let's say I am in a Bash script and am sourcing a file. How do I pass variables to another script after I source the file like this. sed -i 's/ = /=/' $file source $file Let's say file contains ...
1
vote
1answer
21 views

Parted partition drive with small partition at the end

I would like to partition a drive from a script, so that there is a big partition filling most of the drive, then a small one at the end. So far I have come up with. parted -s -- /dev/sda mklabel ...
0
votes
0answers
28 views

Avoid using temp files for pr

I am tailing two files at the same time, side by side, I can't get a version to work that doesn't use temporary files F1.tmp and F2.tmp. I would like to use watch to call this script. Pretty sure I ...
0
votes
1answer
42 views

Linux Shell - How to remove escape characters generated by JQ when json is read with sed?

I am trying to read a json file and use its output in jq to build another json, combining so said json file and other values, and pass it to CURL I read the file with policies=$( sed 's/\\//g' ...
1
vote
2answers
44 views

Why am I getting “Directory not empty” with “rm -rf”?

I'm using macOS with rm tool from GNU coreutils (not macOS’s own rm). So I have a script where I clean up some directory like this: if [ -d "${cleanup_repo_clone_root}" ]; then echo "Cleaning up ...
1
vote
1answer
25 views

How to prevent printing to stdout from an awk **script** (not from cli)

[GNU awk v4.2.1 on Archlinux] Suppressing awk's default print action to stdout from cli is easy and well documented on UL, e.g. here. Doing so from a script gives me headaches. Here's the toy script: ...
2
votes
2answers
61 views

How to know, what SHELL is used when running a script? [duplicate]

How can I output that what shell is used to execute a script? Ex.: the $SHELL variable gives that what is the default shell for the given user. That is ok, but the given user can launch the script ...
0
votes
1answer
14 views

Counting instances in a variable, then reformatting rows/columns within bash script

Please forgive any formatting errors I consider myself a complete beginner. Within a Batch submission script I have a file generated called "nodefile.123" that looks like: bear-pg0208u33b bear-...
0
votes
0answers
12 views

How to detect when NetworkManager loses Wi-Fi connection?

What is the best approach to monitor NetworkManger connections and detect when the Wi-Fi connection has dropped? My goal is to attempt reconnecting after a certain number amount of time disconnected, ...
-2
votes
1answer
34 views

grep routing table & execute command

I'm trying to make a script on my Linux machine that will grep for a specific routing in my routing table and execute command depends on the find. This is what I have so far and it's not working: #!/...
0
votes
2answers
40 views

How to timeout a program with a potentially infinite loop

Suppose I run a program that I suspect to contain an infinite loop, or some other code that might run for too long. I know that in Linux I can do: timeout 1 ./program to give the program a time-out ...
0
votes
1answer
19 views

Can't connect wpa_supplicant to wifi. SSID is not found even though it is listed in scan results

I'm using a script to add a network to my wpa_supplicant.conf and reload wpa_supplicant to connect a new network. Something like this: cat << EOF >> /etc/wpa_supplicant/wpa_supplicant....
1
vote
2answers
42 views

Bash environment variables in non interactive mode

I'm trying to define environment variable for non-interactive console in Raspbian. In theory I need to add the varaibles to ~/.bashrc or ~/.profile or /etc/bash.bashrc or /etc/profile. For example I ...
0
votes
1answer
37 views

Bash Script Case statement (if-not logic)

I wrote a small bash script. It will try to find the word ERROR. If found the resulting value will be non-zero numeric (for example 25. I mentioned in the script but it is variable numeric value), and ...
0
votes
1answer
24 views

Bash script to link networked account directories to local account directories

I'm working on a script that will create a local user account, and link local account directories to networked account directories. The only directories I would like to be created and linked are the ...
1
vote
1answer
37 views

How to parse openssl certificate output into hostname and verification codes?

I have this shell code that reads lines of host names from input file, performs an openssl command to print ssl certificate info, and outputs the results in the terminal. while read x; do echo $x; ...
-2
votes
0answers
47 views

Quickly view e-mail attachments from the command line?

Description of the issue I'm in a terminal at least half the time and, while doing e-mail, that mostly means being ssh'd into a remote machine where I run the alpine e-mail client to check my various ...
1
vote
3answers
54 views

Extracting text from a file when I know its format

I am running a script which will output a file called scServer.scs which looks something like this: 49138@bber0501u29b.bb2.cluster 2 Solution 1 Fluid Flow (Fluent) Solution ...
-3
votes
3answers
102 views

script to translate xml to json

I have 5000 questions in txt file like this: <quiz> <que>The question her</que> <ca>text</ca> <ia>text</ia> <ia>text<...
0
votes
2answers
65 views

What is Linux exit status and list of all status

I'm trying to learn Linux bash scripting and I'm read through the articles in the http://tldp.org sites I saw some kind log clearing scripting I notice that something is used for as an exit status. I ...
0
votes
0answers
14 views

Crontab (Replaced) on Logs - explanation

I've noticed that one of my scripts aren't running and found that it is on last Feb 21. Checked it on the cron logs and found this one: Feb 21 16:07:21 callertag-cc01 crontab[18564]: (ctapp) REPLACE ...
0
votes
2answers
64 views

Replace User Name on one file with User Name plus Company from output of another file

I have 2 text files. One is the list of user names along with the company they work on the same line but separated by a tab space. The second is a output from a weekly generated report that includes ...
5
votes
1answer
424 views

Unexpected behavior of Bash script: First executes function, afterwards executes alias

When I execute the following script #!/usr/bin/env bash main() { shopt -s expand_aliases alias Hi='echo "Hi from alias"' Hi # Should Execute the alias \Hi # Should Execute the ...
8
votes
6answers
795 views

What are the advantages of using `make` for small projects? [closed]

I've seen that make is useful for large projects, especially with confusing dependencies described in a Makefile, and also helping with workflow.  I haven't heard any advantages for using make for ...
0
votes
2answers
79 views

How can I run an executable text file at system startups?

sudo nano /etc/rc.local I have run the above and added the path below. HDD_temp is an executable text file. /home/matthew/@/HDD_temp/HDD_temp However, the file is not run at system startups. How ...
1
vote
5answers
47 views

Running a loop from second line of a file in a bash script

I want to use the below file content as an input of for loop my script. As from second line we have id's which will be used to fetch content from db. cat abc.txt id 27 27 27 27 23
0
votes
2answers
43 views

CLI run multiple commands and close terminal

I want to run the following commands and close the terminal: mysqldump -udatabase -pdatabase database > db.sql && zip db.sql.zip db.sql && rm db.sql && mv db.sql.zip /var/...
0
votes
0answers
82 views

Transfer, rename multiple files using shell script via sftp

Need to transfer a file, rename it and close the connection for each file where I have multiple files using sftp. Server A - Source Server B - destination I need to transfer files form server A to ...
-2
votes
1answer
60 views

script in solaris to send mail when file systems reaches prescribed threshold value [closed]

#!/bin/bash threshold="1" { >/tmp/output for fs in $(df -hk | awk '{print $6}' | sed '1 d'); do chk=$(df -hk ${fs} | sed '1 d' | awk '{print $5}' | awk -F\% '{print $...