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.

Filter by
Sorted by
Tagged with
0
votes
2answers
68 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
435 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
972 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
91 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
244 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
95 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
434 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
76 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 $...
0
votes
3answers
187 views

How to insert a line into a crontab AFTER a key word or string via script

I understand there is a lot of documentation on editing crontabs via script, and I can do this by adding an entry with the following command: line="* * * * * /my/folder/script.sh" ( crontab -l ; echo ...
2
votes
1answer
61 views

Bash scripting and rsync: how to include just some folders and subfolders and what happends if I use ../ as path with --delete

I have a bash script where I'm trying to copy some folders and archives in local with rsync. I have something like this: RootFolder A B C D D1 D2 D3 . . . ...
1
vote
0answers
202 views

Evaluate the similarity between two video files

I'm looking for a method that reliably gives me a "mathematical distance" of two videos from one another. Similar to how the Levenshtein distance can be used to get the distance from a string to ...
0
votes
4answers
61 views

How to append double quotes to password file

How can i append double quote to passwd file with sed or other utilities: Source File: user1:x:1:1:User1:/home/user1:/bin/bash user2:x:2:2:User2:/home/user2:/bin/bash user3:x:3:3:User3:/home/user3:/...
0
votes
0answers
21 views

Can anyone tell me the working method “How to print lines between pattern1 and 2nd match of pattern2?” using sed command\ [duplicate]

Can anyone tell me the working method "How to print lines between pattern1 and 2nd match of pattern2?" [using sed command].
0
votes
2answers
146 views

Separate systemd script for postgresql instances

I have PostgreSQL-11 installed on Ubuntu 18.04 via apt-get, and based from here, I managed to install 2 instances of postgreSQL on port 5432 and 5433. My Question is, can I have separate start-stop ...
1
vote
1answer
41 views

Error in Bash Script Nested Conditional Statements

Getting the error below as I'm sure my syntax is off somehow with the nested conditionals. Basically I don't want to send an empty message to my telegram_bot which throws an error if it detects empty ...
0
votes
1answer
58 views

How to add Tab Space in between awk / sed command in bash

I have two separate lines being consolidated onto one line. The issue is that at the current moment, it is being separated by a space. I would like to know how I can separate the two lines into one ...
0
votes
0answers
50 views

Script connect bluetooth device after booting

I am working with Linux Mint and as far as I know when I boot the PC the bluetooth connection remains opened although you closed it the last session. So at the booting I created the script closing the ...
-4
votes
1answer
132 views

line 220 : return: can can only 'return' from a function or sourced script [closed]

# C A L L C U S T O M E R D E F I N E D P A R A M E T E R S #---------------------------------------------------------------------------------- cd /ERQ/100/DM/SCRIPTS . ./...
0
votes
2answers
553 views

curl and grep(?) to grab specifc string - how?

I need to do some testing using curl against our web farm. Each server has some default page with some verbiage on it like this: "Welcome to webappsrv01" "Welcome to webappsrv02" and so forth. How ...
1
vote
2answers
57 views

Remove duplicate fields with different data

Original file FinalResults.txt contains the following: loginName:name1 memoryInfo:jsHeapSizeLimit:2181038082 session:cabSessionID: sessionStartTime: loginName:name1 memoryInfo:jsHeapSizeLimit:...
2
votes
1answer
30 views

I want to add a variable for the results from the formula of one variable and the beginning of another variable

This is the file name in question OD_Orders_2019-02-19.csv I am trying to create a bash script to read into files with yesterday's date on the file name while retaining the rest of the files name. I ...
3
votes
1answer
351 views

How to execute local script by passing arguments on remote via ssh as a different user?

I am trying to execute a local script on remote server via ssh using keytab authentication. I am able to connect to remote via ssh as sachin(user who gets the ticket) and then I am spawning a bash ...
0
votes
1answer
132 views

lynx proxy authorization

A number of scripts on my system are relying on lynx which in turn can't pass through my proxy. More specifically, lynx successfully picks up the global proxy settings except the user id and password ...
0
votes
1answer
149 views

Bash script interacting with application

I am trying to automate a scanning proccess for a physical application. My script is #!/bin/bash i=1 file="ATLASbins.txt" while IFS= read line do scan=$line cat test.sh | sed "s/ set ...
0
votes
1answer
27 views

If else IP match case with servername

I have multiple servers and want to set up a periodic check so that trapserver(s) has correct trapaddress(es). trapserver 1 as 10.10.10.1 and trapserver2 as 10.10.10.2. However the below script does ...
0
votes
1answer
225 views

file not getting created after redirection and “cp: cannot stat” error

In the bash script below, I check whether a file exists or not and then if it doesn't, I create it and write a simple snippet to it. It worked once(I don't know why), but I guess I have changed ...
0
votes
6answers
262 views

I have a table and I want to extract the row in reverse order of columns in shell script [closed]

The table looks like this: 1|Hunk|First|London 2|Hero|Second|London 3|Will|First|Pow 4|Thomas|Second|Pow 5|Venus|First|Berlin I want to print the output as: Berlin|First|venus|5 i want to print ...
3
votes
1answer
263 views

How to use variables inside back-quotes

I have a bash script that accepts a parameter "$input" and (among other things) directs it into a program and collects the output. Currently my line is: OUTPUT=`./main.exe < $input` But I get ...
0
votes
2answers
29 views

delete folder for all users on Mac

I'm using below command to delete folder rm -rf /Users/*/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Templates.localized/ The command is working only for single user. I want ...
0
votes
2answers
80 views

Changes to bash shell script language? [closed]

i wrote a multipart script that calls rsync a few years ago and it has always worked. After a year of no use and alot of debian apt-get updates, now the script stopped working. Main2Network1.sh ...
0
votes
1answer
57 views

Killed process starts again automatically!

I've several Rasberry Pi with an app written in QT that automatically start at logon... the automatic start is made through the /home/pi/.config/lxsession/LXDE-pi/autostart file. I've inserted in this ...
0
votes
2answers
354 views

ffmpeg: filenames with spaces from bash script

I have composed the following bash script to automatically concatenate mp3 files using ffmpeg: i=0 for f in "${@:2}" do filter+="[$i:a:0]" i=`expr $i + 1` files+="-i $f " done ...
1
vote
1answer
310 views

How do I properly change the debian default python 2.7.9 to python3 or another version? [duplicate]

what is best-practice for changing the default global python interpreter on my fresh debian-based linux node to python3.x? When I create a fresh Debian or Ubuntu VM, one of the first things I do is ...
-1
votes
1answer
58 views

Command Line Options for a script

$ cat test15.sh #!/bin/bash # extracting command line options as parameters # echo while [ -n "$1" ] do case "$1" in -a) echo "Found the -a option" ;; -b) echo "Found the ...
-2
votes
4answers
103 views

Json. How to add a sentence after :

The following is an extroct from a json file, that I have: }, { "name": "asdasd", "script": "dsad.js", "merge_logs": ture, "error_file": "/ofghfghgfh.log", "out_file": "/...
3
votes
2answers
99 views

How to transition smoothly and repeatedly between two videos using command line tools?

I want to output a video using two videos as input, where these two videos fade (or dissolve) into each other in a smooth and repetitive manner, every second or so. I'm assuming a combination of ...
0
votes
0answers
57 views

How can I parse through a log file, extract certain values and construct a tab or comma delimited text file?

I am trying to convert a pre-formatted section within a log file into a comma or tab delimited tabular view. Here's a sample section contained in the log file: Appliance-01> home Appliance-01>...
1
vote
4answers
425 views

How do I get systemd to correctly manage a script with background processes?

I have a shell script which runs three programs in the background, a few in the foreground and then trap and wait, and I have set up a unit file so systemd can start it and restart it if it fails. I'...
1
vote
5answers
130 views

IF construct in Solaris box to compare hh:mm:ss

I had created the below script which does the comparison between hh:mm:ss format variables. #!/bin/sh lag=00:00:00 MAX_LAG=00:05:00 echo $lag echo $MAX_LAG if [ "$lag" \< "$MAX_LAG" ] ##if [ "$...
1
vote
3answers
900 views

Remote Command executed via ssh does not return proper return code. Return error code is always “0”, even condition failed

I am not getting proper exit return code during execution of remote script on a Linux machine. This script is intended for checking whether a user exists or not. My Script is below :- #!/bin/bash ...
1
vote
1answer
696 views

Adjust fan speed via Fancontrol according to hard disk temperature (Hddtemp)

How can I adjust fan speed according to hard drive temperature via Fancontrol?
2
votes
2answers
56 views

Scipt to run only once during given time

I need to have my script run only once during given time. Eq:- first time script will run at 9:30 but if someone trys to run my script again b/w 930 to 945 say at 940 either manually or via job, it ...
0
votes
2answers
76 views

How to debug a script by removing the “if”?

I have the following code: debug=$? function a { su - javi -c "uptime" return $debug } function b { su - javi -c "cat /etc/redhat-release" return $debug } function c { su - javi ...
8
votes
2answers
863 views

Multiline command : comment out one line

I like to use the following format in scripts for commands with a lot of parameters (for readability): docker run \ --rm \ -u root \ -p 8080:8080 \ -v jenkins-data:/var/jenkins_home \ -v /var/...
-1
votes
1answer
35 views

How to create a new workspace through script?

I usually create new workspace whenever i start a new activity. Since i work on multiple task, i want to isolate them from one another. So every time i create a workspace, i have to do some set of ...
4
votes
2answers
602 views

Shell Script while loop: [ around a pipeline missing `]'

The shell script I'm trying to use keeps giving this error: $ ./script.sh: line 2: [: missing `]' grep: ]: No such file or directory The line is part of a section trying to check if a particular ...
-1
votes
1answer
49 views

Did I Mess Up My Computer with Recursive rm of '*.h"

So I was basically trying to print all files with a .h file extention out of curiosity, and so I simply googled how to do that. Unfortunatley, I didn't pay close enough attention to the answer and ...
0
votes
2answers
318 views

cp command not copying to the correct directory? [closed]

For my classes we have all of our homeworks and assignments in a read only folder so I want to copy all those files (they aren't very big) to my personal folder on ssh login. I so far have been able ...
0
votes
1answer
38 views

How to easily convert Debian script to RPM script? [closed]

I'm aiming to translate a Debian package to an RPM package to install it on a CentOS Linux 7 (Red Hat).I used alien to accomplish it: alien --to-rpm --scripts --keep-version debian_pkg.deb. However, ...
0
votes
1answer
35 views

script to look up and compare definitions of words in 2 online dictionaries

I'd like to look up different definitions of a given word, e.g. "obey", in two or three online dictionaries of my choice, e.g. Longman, Cambridge, Oxford. Then have them listed one by one in Terminal. ...