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
2
votes
1answer
66 views

Launch a command when connected to a host

In a dormitory I live in the access to Internet is somehow clumsy. The procedure follows Connect to the network (via WiFi/Ethernet) Login by ssh sshpass -p password ssh login@domain.edu.pl Moreover,...
2
votes
1answer
1k views

How do you make a toggle key using Autokey?

I want to use Autokey to toggle the e key on and off in a program called "xyz". So if I press e, the program thinks I'm holding down e. I press e again, it thinks I released it. How do you do this ...
2
votes
0answers
435 views

How to disable AC power supply from CLI

This article among others suggested the following to prolong battery life: Keep cool. Operate in mid SoC of 20–80%. Prevent ultra-fast charging and high loads (most Li-ion) The main issue here is ...
2
votes
0answers
282 views

“Restart” a process in the same terminal?

I put "restart" in quotes because the following question on SO illustrates what I'm trying to do: https://stackoverflow.com/questions/27957091/restarting-a-process-in-the-same-linux-terminal I'm ...
2
votes
0answers
131 views

Restore Trash Script not working

I made a script to send a file to a trash folder... echo "Are you sure you want to move this file to the Recycle Bin?" "(Yes/No)" read ans case "$ans" in Yes) echo "$(readlink -f "$1")" >> "$...
2
votes
1answer
138 views

Is there a version of script that plays nicely with vim?

man script says: Certain interactive commands, such as vi(1), create garbage in the type‐ script file. Script works best with commands that do not manipulate the screen, the results ...
2
votes
1answer
152 views

Renaming the files and move to other path

I need to rename the files given below and move to some other path 1234551abcde20140718023216001.txt.809047512.2014_07_07_13:47:44 000001abcde20140718023216001.txt.34568.001.2014_07_07_13:50:44 ...
2
votes
0answers
82 views

Automating startup tasks

I have a "morning ritual" that occurs on every boot of my machine: starting up a few browser tabs, starting up skype, starting up terminator and subdividing some screens, etc. Is there any tool that ...
2
votes
1answer
133 views

List Mails by subject

I'm writing a script to send mails from a mailbox on a remote server and a script to check if the mails are received at another remote server. For this I have configured mutt. What I now need is to ...
2
votes
1answer
383 views

How to emulate a KWin effect by command line?

I would like to apply the Toogle Invert Effect when I start my system. So, I need to know how to call this KWin effect using the terminal. OBS.: I'd tried xte "keydown Meta_L" "key i" "keyup Meta_L",...
2
votes
2answers
671 views

Script that unpacks a initrd, allows editing of the preseed.cfg and the packs it to cpio and gzip again

I want to program a script that allows what is said in the title. So basically I gunzip the initrd, than unpack the cpio, open vi to allow editing, save, pack with cpio, and gzip again, so nothing ...
2
votes
1answer
1k views

How to copy/merge two directories and if two files have the same name rename the older one appending its modification time

I have several directories with files which mostly have the same name but might be different and I need to have all these directories merged into a new one. I need to be able to compare the same named ...
1
vote
0answers
36 views

Shell Script to read process file and Do

I am considering if I can create .sh to read CPU process file and if the output numbers higher or equal 70 failed else success. Sample : process limit % --------------- 42.45 52....
1
vote
0answers
16 views

How to increase the duration of the transition effect between multiple video cuts in this ffmpeg `-filter_complex` command

As instructed in Gyan's solution to this question, ffmpeg can be used to interleave two audio/video inputs with a lapse dissolve transition. For example, this command will divide each input into cut ...
1
vote
1answer
36 views

Kill bash script if Terminal is closed

Problem is that i have a bash script that requires user to login and perform operations. Everything is logged in a log file. Now issue is if user exits the terminal, the scripts keeps running and ...
1
vote
0answers
66 views

Using a file list to apply a script over a set of similarly named files (unix)

I have a set of files that are named like this: NAM11_BW415_R1.fastq.gz NAM13_BW968_R2.fastq.gz NAM17_AC_Barrie_R1.fastq.gz NAM3_PI648600_R2.fastq.gz NAM7_Glenlea_R1.fastq.gz ...
1
vote
1answer
42 views

How to write an “expect” script that checks if the supplied password matches one of multiple possible passwords?

I want to change the password on my server. There are four possible passwords that should all be accepted for changing a password on the server. To achieve this I want write an "expect" script ...
1
vote
0answers
22 views

systemd service start after network online and time synced

I made a system service for a python script, I want it starts on boot after the server is online and the time is synced correctly. What do I have to add in .service file? I tried in [Unit] with ...
1
vote
1answer
25 views

Writing logs for openvpn in Ubuntu18

I've installed openvpn on Ubuntu18, and it works. I'd like to have a log containing only the times when users connect and disconnect. Found a hint how to do it at [https://github.com/furlongm/openvpn-...
1
vote
0answers
57 views

Setup Automation - Firefox and Addons

I am improving my setup script for new installs and want it to include setting up firefox. One big problem I found is, that it is not possible to install addons via CLI that automatically get updated ...
1
vote
1answer
36 views

Attempting to only copy files that have changed within the last day while maintaining folder structure

I'm attempting to find and copy files that have been modified within the last day. While doing that I'm trying maintain folder structures under dir1. There are many subdirectories under dir1 and data ...
1
vote
0answers
166 views

How to get the average CPU usage over the past 10 seconds in bash?

I need a command that would echo the average CPU usage over the past 10 seconds in Ubuntu 18. Each of the following conditions must be met: It must be lightweight with a very small footprint, ...
1
vote
0answers
231 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 ...
1
vote
0answers
237 views

systemctl doesn't work from crontab

I'm trying to run a script calling systemctl from crontab but the command is not being executed. Other scripts work fine from crontab. The script works when executed in a terminal. This is the script:...
1
vote
0answers
261 views

How to script AT command to modem?

Every time my USB modem (/dev/dlinkModem) gets unplugged it defaults to "radio disabled mode" (AT+CFUN:4). I can easily enough call AT+CFUN:1 through the minicom application console to enable radio ...
1
vote
1answer
42 views

How to extract data from csv file with modification to data

For eg i have a file called test.csv containing emp1,dep1 emp2,dep2 emp3,dep1 emp4,dep3 emp5,dep2 expected output is emp1 works in dep1 emp2 works in dep2 . . emp5 works in dep2
1
vote
1answer
228 views

Ping - big packet size problems

I have some problems with pinging hosts with big packet size. I'm doing some research on latency between one configuration and another. I have written bash/zsh script to make it simpler that pings 8....
1
vote
0answers
36 views

Adding a tag to variables in script that creates config file

What is the easiest way to add a tag? For example, in my script that creates a config file, I have the line echo "Variable = ${arr[0]}" >> $CFG_FILE So, this takes the respective entry from ...
1
vote
2answers
69 views

Printing a dynamic list of month days vertically

I need to write few line in a code that I use in my study, and I really gave up! currently, i can list the days of a month and the equivalent day number but I can't link this to the system clock so it ...
1
vote
1answer
49 views

Boot option for mounting read only and run script?

I would like to make a special boot option in grub2. When this boot option is selected as a boot target, it will mount as read only (instead of the normal read/write mode), and run a script that doesn'...
1
vote
0answers
170 views

automated tool (or script) for cleaning systemd journal of corrupted files?

It is my understanding that the systemd journal cannot repair or fix errors revealed by: journalctl --verify Here's an example of an error I just saw. I routinely see errors like this on all the ...
1
vote
1answer
45 views

How to play a media file with a sequence of controller commands?

I would like to know if I could find a way to bind a combo like the "hadouken" (Hadouken is a combination of movement of a joystick: down, down-right, right + button ) of street fighter to make an ...
1
vote
2answers
42 views

merge rows of one file based on key columns

I have a text file which has ~ delimiter values. first 4 columns are the key columns and based on that 5th column value needs to be extracted. The file looks like this: S1~D1~1~1~abc S1~D1~1~1~bef S2~...
1
vote
1answer
237 views

Not able to exit from interactive mode for yarn top command

I have a bash script which is on serverA. This script will ssh to serverB and runs yarn top command, pulls the metrics and put into the file(test.txt) on serverA. Below is the command which I am using:...
1
vote
1answer
224 views

Autorestart program (script) when reconnecting to ppp0 with sakis3g, UMTSkeeper

I have a problem. Hardware and software I'm using: Raspberry pi, 3G modem - Huawei e1550, sakis3g and UMTSkeeper to handle connection. Also I'm using https://github.com/Lora-net/packet_forwarder for ...
1
vote
1answer
51 views

Is there a special device that causes read to block forever?

I’m looking for a variant of /dev/null that causes read to block forever, rather than returning EOF immediately. Does such a device exist? I could probably create a named pipe (via mkfifo) to achieve ...
1
vote
0answers
136 views

How to overcome HiDPI problem with Qt-based apps in Gnome environment?

I seem to have an HiDPI issue with Qt apps only, displaying extra large menus and toolbars when system dpi setting is 100+ The easiest solution for this I guess would be forcing a fixed dpi setting ...
1
vote
1answer
932 views

rc.local can't find my script

I am trying to get my script to run on startup. I am using Ubuntu Server 16.04. Here are the exact contents of /etc/r.local. #!/bin/sh -e # # rc.local # # This script is executed at the end of each ...
1
vote
2answers
3k views

Shell script to ls and execute command on ls result

I have a list of folders inside a folder in ubuntu. ie. Under /mnt/source/customcode/files/brands/ root@a919794ec280:/mnt/source/customcode/files/brands# ls -la total 236 drwxrwxrwx 19 1002 root ...
1
vote
2answers
106 views

How check flags on systemd?

I try run clickhouse on old CPU, but get error: Illegal instruction Clickhouse required CPU flag SSE 4.2. How check flags on systemd ? Or how write this block on systemd without run bash script? ...
1
vote
0answers
789 views

Automatic Login with cURL without php

I'm working in a little project using a script to do scraping. I'm trying login in https://www.plusdede.com/login, it's a simple login with a numeric captcha. The code which is important is: <div ...
1
vote
1answer
590 views

Why is my udev rule not working?

I need to automatically run my script /var/www/html/configWWW when any USB is plugged in to my Raspberry. UDEV RULE - /etc/udev/rules.d/myRule.rules ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="...
1
vote
1answer
658 views

How to get monitor width using xrandr --query?

I have a shell script, that loops through xrandr to find connected monitors, which get assigned inside of a variable. Inside that loop, I want to have another loop that determines the width of said ...
1
vote
0answers
609 views

How to speed up awk script that uses several large gzip files?

I have two data files: file_1.in, containing over 2k lines like "12 AB0001": 10 AB0001 11 AC0002 12 AD0003 ... A list of *.gz gzipped files (about 1 to 3 million lines) I should extract and parse ...
1
vote
0answers
274 views

Linux - Ubuntu - GUI - Remote Mouse and Keyboard from 1 master to 10 slaves

Is it possible to replicate mouse and keyboard actions to multiple devices? e.g. listen on ubuntu 1, then replicate the exact mouse and keyboard actions to ubuntu 2, ubuntu 3, ubuntu 4 and so on. I ...
1
vote
3answers
239 views

How to rsync content from another machine through multiple machines?

I have 4 linux machines having name A,B,C,D and I want to rsync some content from machine A machine D, but A is not directly connected to D and but A is connected to B and B is connected to C and C is ...
1
vote
0answers
33 views

Opening applications in a different desktop from a command line

Is there a bash command which can open a particular application in a different desktop (virtual desktops) in KDE Plasma 5.8.7? I'm trying to make a script file which when I run will make my entire ...
1
vote
0answers
103 views

Run multiple screens and attach them for a split view

So I'm new to screen and I've been using this .screenrc for now - https://gitlab.com/joaopizani/env.screenrc-ftw. I'm trying to make a script that, given a target host, will do the following: Open a ...
1
vote
1answer
157 views

pass the value of variable from a script to another script from another server

I have a script that will ssh to another server. Script A will get the value of $variableA, then will ssh to another server to execute a script B which will need the value of $variableA. I tried ...
1
vote
1answer
349 views

Run a script immediately after login before /etc/motd is read

How can I run a script immediately after login before /etc/motd is read? I' m not looking to run the script from within /etc/profile.d or ~/.bashrc or ~/.profile