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.

434 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
0answers
26 views

Shell script to execute other script not spawning other scripts

I have a shell script running in a while loop. The script accepts a number as an argument so in ps you would see something like /path/to/script.sh 2. Every 180 seconds, it should be spawning a PHP ...
0
votes
0answers
25 views

How to run 2000 processes with chroot

I have a program that needs to be run in about 1000 instances, each in a different independent directory (/mnt/x_1, /mnt/x_2... /mnt/x_1000). What I'm currently doing is mounting /bin /dev and /etc in ...
0
votes
0answers
33 views

How to set variables in nested ssh session

I want to set some variable in ssh session which is nested. ssh host1 << EOF ssh host2 << EOF1 myvar="Hello" echo=\$myvar EOF1 EOF What is wrong in this bash ...
0
votes
0answers
19 views

Ubuntu 14.04 ,looking for script auto restart eth0

I got the problem on 14.04.3(default install iso, do not apply network update or upgeade to 14.04.6), the system sometimes network fail, can't ping other one and arp get the mac address show ,i need ...
0
votes
0answers
25 views

Inserting column headings in awk command

I have a raw file (gx.txt) having below sample contents shown below. TIME;PCS/Main:GxCCAInitialSuccES;PCS/Main:GxCCAInitialSuccSILP;PCS/Main:GxCCATermSuccES;PCS/Main:GxCCATermSuccSILP;PCS/Main:...
0
votes
0answers
255 views

How to replace CTRL+C shortcut with same action plus xclip save copied selection command?

I am trying to be able to save/log all clipboard selection copies to a clipboard_histroy.log file. I want this to be able to simply append each copied selection to the log file but at the same time ...
0
votes
0answers
197 views

Script not executing with ssh and sshpass

I have a script in my .gitlab-ci.yml which is not being executed. Here's the script: - apk update - apk add --no-cache openssh-client sshpass - sshpass -p "${USER_PASS}" ssh -o ...
0
votes
0answers
196 views

Building a script to find a file if exists and grep for a string

Following K7AAY and 0xSheepdog advice I'll rephrase. I need to create a bash script where it will grep a log file that is generated daily when a file is sent in a range of time of the day. The ...
0
votes
0answers
55 views

randomly generated words to a form using curl

What I want to achieve is to post a form containing 3 fields (forename, surname and email) to a url, but i want the entries to be randomly generated. I want to generate a random word using; { head /...
0
votes
0answers
55 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
47 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 ...
0
votes
0answers
30 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
0answers
13 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, ...
0
votes
1answer
30 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 ...
0
votes
2answers
133 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
482 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 ...
0
votes
0answers
60 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 ...
0
votes
1answer
62 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
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>...
0
votes
1answer
36 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. ...
0
votes
1answer
83 views

Automatically save the text-only of every web page visited?

I'd like to automatically save the text of every web page I visit, to it's own corresponding text document, not html document. I am not looking to save all the styling and additional repeated html ...
0
votes
0answers
24 views

Who are known Wireless Networks Stored, and how does auto connect work?

I'm trying to build a script that auto connects to a given network (providing ESSID and Passphrase) and I want to store them, so when ever it's not connected, It searches for the given network, ...
0
votes
0answers
25 views

Command to append new logs content, generated in a directory to the end of a file

I've got an IDS which creates log files inside a directory. These logs all start the same ie, IDS_log_XXXXX. I have a perl script setup which would email me when these logs would contain certain ...
0
votes
0answers
84 views

Change position on the graph screen gnuplot in bash script

i have a script in bash that read the file Throughputtx.txt and print this information in a graph of GNUPLOT, but this graph goes to the left side of my screen and I want it to be printed in the ...
0
votes
0answers
56 views

Shell script - directory size

I have to create a script that calculates the size of a directory given as an argument in bytes, like ./du.sh dir. Optionally I have 2 other arguments: ./du.sh dir 1000 files.txt, where 1000 stands ...
0
votes
1answer
57 views

Script “7 days log tar and then remove the 7 days logs and exclude the tar file after next 7 days”

I am trying to create a script such that it could tar.gz all the previous log of per 7 days log and exclude the tar file in next run. Is the script ok or should I have to make a change find /home/...
0
votes
1answer
49 views

Truncate from beginning in Rofi

I'm using this command for a rofi-locate script (source): xdg-open "$(locate $query | rofi -threads 0 -width 90 -dmenu -i -p "locate:")" Currently all long path results are truncated from the end, ...
0
votes
0answers
75 views

How to stop anonsurf from starting when system starts up

I am using anonsurf package to be able to visit some websites that are filtered by my ISP. My problem is that although I don't need anonsurf to be enabled for everyday use, it starts at the system ...
0
votes
0answers
25 views

Terminal Hangs when running bot

I have a bot installed on my Azure Linux VM running Ubuntu 18.04. I am running the command to start my bot, and it returns an error (see below). The console freezes as well apparently because it ...
0
votes
1answer
784 views

How to count the number of arguments passed under condition?

I'm trying to create a shell script taking as argument a series of averages and assign for each note an observation, example : There are 5 averages that are introduced. There are 2 notes that are: ...
0
votes
2answers
105 views

Problem with crontab

My script which starts a process and writes the PID of that process to file. This works as it's supposed to when I execute it from shell: process & echo $! > /home/xxx/PIDs/process.pid But ...
0
votes
1answer
102 views

sed? - replace part of line if match from another file found

I need to take one file containing lines same as this fake one: 232.232.232.256:2001, 232.200.200.256:2314 And i need to run trough another file *.json, and find all occurrences of first "IP" and if ...
0
votes
1answer
53 views

How to run the same command to execute a file in multiple directories?

I want to do the following, I have a set of directories: e.g) 400K 500K 600K and so on In each directory I have a "run.pbs" file, that I want to submit through batch with "qsub run.pbs". I was ...
0
votes
0answers
79 views

Is this segment fault raised when running `shuf`?

I have a script, where there is a line: eval for i in \{"$1".."$2"\}\; do [ ! -e "$3"/\$i.\* ] \&\& echo \"\$i\" \; done \| shuf \| mycommand "$3" which means: first create a sequence of ...
0
votes
1answer
2k views

Creating a config file

I want to create a Bash script that creates config files. I want this file to be able to be called by another script that sets parameters in the config file. (For additional but unrelated info to keep ...
0
votes
1answer
142 views

Shell script which returns elapsed time, memory usage and CPU usage of executed script

I need to write a bash script which will be able to return elapsed time, RAM usage and CPU usage of executed script. my script: #!/bin/bash STARTTIME=$(date +%s%N) #here is script which needs to be ...
0
votes
3answers
91 views

compare two IP address using bc

I am trying to compare two IP address using bc command however the IP with lower numeric value is not being trapped in the test. Here is my code: TEST=$(echo "$i < $IP_BRD && $i > $...
0
votes
1answer
39 views

Fetching title of browser

[Fetching user title] Seen a post prior of someone posting how to do it by single account I wish to do this from the range 1-1000 and have it output to >> .txt Example: x@nine:~# wget -qO- 'http:...
0
votes
1answer
535 views

Converting csv file (generated by db query) to html and color code the table based on Column Value

(Using Shell Script) Need to generate html report from a CSV file which is an output of a DB query and then color code it based on column values. For example, from the given CSV ile, if any cell under ...
0
votes
1answer
308 views

Running commands as different user from bash script

I have 2 users: usr1 and usr2. Neither is a root user. usr1 starts a bash script. And from the script, I want to run some commands as usr2. I understand that the way to do it is: su -l <usr2> ...
0
votes
1answer
39 views

How to run files automatically after I power on my raspberry pi?

Is there anyway to have files (texts/videos) saved in a specific folder to run automatically once I start up my raspberry pi? I am creating a LAN of raspberry pi's with one central laptop connected ...
0
votes
0answers
352 views

usr/lib/sendmail doesn't work

On one of our company server, suddenly /usr/lib/sendmail stopped working. We have a call to it in few scripts (owned and ran by oracle user) and none of them is able to send an email out, even ...
0
votes
2answers
537 views

change date/time format from yyyymmddHHMMss to dd/mm/yyyy HH:MM:ss

How do I change date/time format from yyyymmddHHMMss to dd/mm/yyyy HH:MM:ss which is displayed as an output (eg. JOBNAME1 STARTED AT 20180904152402) from a command... grep JOBNAME1 | sed -e s/|/ /...
0
votes
2answers
35 views

Bash script: parse subdirectory and not current directories

I'm trying to parse subdirectory names, but the output breaks the names up into individual words. Eg. If the subdirectory name is "Hello World", the output will be: . Hello World The ...
0
votes
1answer
153 views

bash script - logrotate output rename

When executing logrotate it shows following: error: error creating output file /var/log/remote/172.29.202.29/contrail-vrouter-agent.log.1: File exists error: error creating output file /var/log/...
0
votes
0answers
191 views

Automate process of removing tap devices

I am playing about with tap network interfaces for a project, to create a network configuration in QEMU that allows the host and guest to be on the same network. I am using this script to cleanup and ...
0
votes
1answer
29 views

How to use parallel correctly in this situation?

I have a file with multiple URL's in it (separated by a newline) and want to execute a bash command for each line. Here is the command: xargs -n1 -I+ ./info.sh https://+/.info/ +/ How can I execute ...
0
votes
1answer
34 views

The -s argument for the read command messes up the output

So my user adding script again, I noticed that, if I have the -s argument for the read command (when getting the password), the output gets messed up. This is the code again: #!/bin/bash # Only ...
0
votes
0answers
142 views

Matching opening and closing if statements in shell script (if…fi) using PHPStorm, vscode

I hava bunch of these nested if..then...fi 's if [ "${var}" = "NA" ] then if [ "$var" != "SAM" -a "$fileFormat" != "XED" -a "$Format" != "TED" -a "$Format" != "ESTA" ] then ...
0
votes
1answer
355 views

capture output from java

I am trying to do that : #!/bin/bash set out=$(java -jar -Xmx1024m myJava.jar '$1' '$2' '$3' '$4') echo "$out" python myPython.py $out but with no success... I tried with and without quote (because ...