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.

612 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7
votes
1answer
634 views

Check if a remote machine is in a Veritas cluster

How can I verify that a remote machine is part of a Veritas cluster? I just created the following ssh command to verify if the remote machine is a VRTS cluster or a Linux availability Red Hat cluster ...
6
votes
1answer
642 views

Mac equivalent application "shortcat"

There is a mac application called Shortcat and it make me envious. For those of you averse to clicking links here is a summary: Keep your hands on the keyboard and boost your productivity! ...
5
votes
1answer
338 views

How to create a real copy of file descriptor stdout and stderr without using unbuffer / script / tee just with bash built-ins?

My goal is to duplicate, redirect all output (stdout and stderr) of an application (apt-get) to a file while retaining the usual behavior of the application (apt-get), stdout and stderr. How to ...
5
votes
0answers
268 views

programmatically alter kde file associations

Problem: In kde I want to remove a particular file association from every file type Details: I wanted to try out clamTk as a companion to clamAv. It didn't suit my needs so I uninstalled the ...
5
votes
2answers
4k views

How do I reset a USB device using a script?

I have a USB GSM modem that does not always work property (Huawei E367u-2) Sometimes it gets reset (USB device disconnect/reconnect in logs) and when it comes back up, it has different ttyUSB numbers. ...
5
votes
3answers
3k views

Find and list duplicate directories

I have directory that has a number of sub-directories and would like to find any duplicates. The folder structure looks something like this: └── Top_Dir └── Level_1_Dir ├── standard_cat ...
4
votes
0answers
168 views

How to dynamically control the audio volume based on current decibels

Since the Internet videos have different sound volume levels I am wondering is there a way to dynamically decrease the audio volume if it's above certain decibels to a normal value. Could someone ...
4
votes
1answer
295 views

How do I schedule a cron task to run

I'm looking to crontab a script every hour starting Friday at 5pm... ending Monday at 5am. This script checks if it's completed this week and if it's currently running. If no/no, start task. Off the ...
4
votes
1answer
251 views

Remote script cleaning up

I run a remote script using ssh: local script: local_command ssh -p 222 user@server 'sh -s' < ./remote_run.sh remote script: some_command & sleep 10000 trap 'echo exiting' SIGINT SIGTERM ...
4
votes
1answer
1k views

GRUB 2 scripting: convert device name in GRUB notation into a Linux device name

I'm trying to use partition labels (or UUIDs, that does not matter) to select root partition without use of an initrd/initramfs. With initramfs, this is fairly easy: root=LABEL=... or root=/dev/disk/...
3
votes
0answers
56 views

How to run a script when a directory is accessed?

I want a device mounted to a mountpoint only when it is needed, when it is accessed (for the first time). How to run a script when a folder is accessed in Linux (or Ubuntu)? Please note that the ...
3
votes
2answers
315 views

Parsing csv file to filter rows basing on a matching set of characters from a column value

Consider the following csv file: A,3300 B,8440 B,8443 B,8444 C,304 C,404 M,5502 M,5511 The real csv file is really big (around 60,000 rows) but I only included a small version for ...
3
votes
3answers
155 views

How to grep data of a new line when capturing a keyword?

I have a file which contains below sample line having a common keyword P00001121 in each line. [H00,P00001121] CHANNEL__OPEN:TCP_ADDRESS='10.32.130.202' TCP_PORT='80'" [H00,P00001121] COMMS_QUEUING:...
3
votes
1answer
945 views

Redirect echo in trap function back to stdout

I'm currently having an issue getting echo statements in my trap function to be printed to stdout. I'm redirecting all output (error and stdout) to a log file from a command that I run. But if it hits ...
3
votes
1answer
363 views

How to generate (git) diffs with <n> characters of context?

The --unified=<n> option lets you set the number of lines; is there a way to do the same for characters? example limit the context around the changes to X character(s) when using git diff --...
3
votes
0answers
1k 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:...
3
votes
1answer
776 views

Script or Program to discover hosts on network

Explanation: I need a script or program to discover devices on my network. I was thinking maybe doing the scan with nmap and I need to display just the name of device, what it is, and also the ip ...
3
votes
1answer
439 views

Advance autologin via 2 jumphost/passphrase

I need to find a way to autologin on Remote Machine. There are several way in which we can do this but this is little tricky for me. Auto Login to a remote machine and execute command or script and ...
3
votes
0answers
556 views

How to rsync files when a USB stick is mounted

Tried a little project to aid in transferring control files from my home computer to my work shop computer. The outcome confuses me. What am I doing wrong? The home computer is running Fusion 360 ...
3
votes
1answer
1k views

Upload to youtube using shell script

I've searched the youtube API but still not clear whether this is possible. I have a shell script that uses FFMPEG to convert a video. After being converted I want to have the video automatically ...
3
votes
1answer
2k views

mv file/folder with blank-spaces in its name doesn't work - LFTP

I have 2 spaces: My Synology NAS. And my FTP. If we assume that some files on my local NAS are also in my FTP repository, I want to move some files on my local NAS AND on my FTP on different folders. ...
3
votes
0answers
1k views

Converting script from init to systemd

I am moving from Ubuntu 11 to 16, and would like to convert custom-made scripts to work with Ubuntu 16 I have started and completed First init script but need a bit of help on Second init script. I ...
3
votes
2answers
1k views

Bash Scripting: How do i limit the amount of options in a select loop?

When you use the select loop to present the elements of an array as an option, it will display it all at one time. Is there a way to present the options to the user for like 25 options at a time?
3
votes
1answer
3k views

How to kill inactive user logins on Solaris?

On a Solaris 10 server if i do a w, I get this: 12:26pm up 85 day(s), 1:13, 6 users, load average: 0.38, 0.36, 0.38 User tty login@ idle JCPU PCPU what blah pts/1 ...
3
votes
3answers
82 views

Converting rows to row groups

Can somebody please help me with the below conversion shell script ? Source File File 1 : for example EXCHANGE_ID : 192, 410, EXCHANGE_DTTM : 2015-06-11+02:18:40+0000,...
3
votes
0answers
136 views

Automatically restarting process in the X server

I would like to know how to have a process that starts with the X server and automatically restarts when it stops running. I am running Ubuntu 14.04 with a KDE 4.13.3 desktop. I am running the ...
3
votes
0answers
96 views

End recording once silence is detected

I've been using something like this up to now: End sox recording once silence is detected But now I'd like for the audio source and recording mechanism to be separate. I can get the source as an ....
3
votes
0answers
64 views

Notifying program that X session is shutting down

Ok. I understand X session is a bit vague here so let me clarify what I mean by the phrase. I mean the situation where a person has been presented with a display manger screen ( eg xdm, kdm, gdm, mdm, ...
3
votes
0answers
1k views

gnome-terminal cmd leaving processes open after closing parent window

The following simple command should demonstrate my issue: gnome-terminal --tab -t "Tab 1" -e "/bin/bash" --tab -t "Tab 2" -e "/bin/bash" This should open a new window with two tabs and an active ...
3
votes
0answers
447 views

Using tcpdump to log blacklisted IPs

I am using tcpdump to log traffic outbound on a network. I would like to be able to log traffic on a host or IP-only basis but then I would like to be able to log large numbers of potentially ...
3
votes
0answers
2k views

Cron file syntax checker/validator script

Does anyone know a script (bash, perl, php ...) to validate the syntax of crontab files? I found this http://www.intuitive.com/wicked/showscript.cgi?053-verifycron.sh but just Vixie cron notation is ...
2
votes
0answers
38 views

Blink LED on different times on Linux

I made a python code to blink LED on Ubuntu installed on Raspi3b. Its running and i could blink. Next steps are to blink different times when i power on, after ssh active, end of shutdown. I am very ...
2
votes
0answers
20 views

Is there a way to run a hook (i.e. shell script etc.) when an audio device is opened or closed?

I'm running MPD (Music Player Daemon) on a Raspperry Pi, connected to a somewhat high-power audio amplifier. The amplifier gets quite hot if left on 24/7 and I'm worried about it burning itself out, ...
2
votes
0answers
58 views

Struggling with systemd and user permissions for backup script

I could use some help with figuring out the right way to accomplish what I need using systemd. I feel like I have backed myself in between a rock and a hard place and am not sure where to go. here is ...
2
votes
0answers
19 views

Receive notification new messages localhost MAC OS?

I need to receive notifications when my backup script is executed successfully. First I tried to send an e-mail to Thunderbird on localhost, but newer version of Thunderbird does not have Unix mail ...
2
votes
0answers
46 views

Get the full path of running script from /proc

If a running script was called directly, as in not by calling its interpreter with the script's path as an argument, how can the full path to script file reliably be retrieved regardless of the ...
2
votes
0answers
20 views

Script configuration issues

My purpose is to allow user A to run a specific script owned by user B but with user B’s profile loaded. This is on a Solaris maachine. I have users A and B, I set this line: in the sudoers file, so ...
2
votes
1answer
224 views

Which Window Managers are Shell Scriptable?

I'd like to start doing more powerful things on my desktop with (simple!) scripting and would like to know which environments/ window managers support this. Example: For web development, I have to ...
2
votes
0answers
56 views

Is it possible to delete files on linux before exporting it like virtual machine?

I know that before exporting a virtual machine you need to shutdown the guest OS. I need to delete a file on the system before exporting the machine or after importing it and starting of loading the ...
2
votes
0answers
71 views

Fedora: Create multiple workspaces with a script

At the moment I'm using Fedora with Gnome. I want to create a script which will be able to start the applications on different workspaces. For me it's clear that I could create a script which just ...
2
votes
1answer
431 views

Shutdown from a script executed by cron as root

Background I'm trying to write a script (see end of the question) that checks the temperature on Raspberry PI and shuts it down automatically if it goes too high. The script would be run by cron, ...
2
votes
0answers
68 views

Filter Bluetooth Devices from ACPI Command Output

I have a battery status script for my laptop which parses the output of acpi -b. Since my laptop only has one battery this has worked fine for years. However, I recently purchased a bluetooth ...
2
votes
1answer
476 views

Copying/Moving folders where destination folder already exists

I am writing a bash script to copy/move a folder called "folder" to a directory that already contains "folder" and I would like the contents to be merged. I am attempting to use a solution from this ...
2
votes
0answers
222 views

Detect network interfaces with carrier on boot

I have a Debian system with more than one ethernet port. I'm currently running a script on boot which assigns a static IP to one of the ports (by updating /etc/network/interfaces and restarting ...
2
votes
0answers
87 views

How to trace script execution events

My goal: To receive events from the kernel when a file/script is opened for execution with the absolute path of the file (or maybe the working directory, to resolve the absolute path of the file). I ...
2
votes
0answers
69 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 ...
2
votes
2answers
35 views

edit a file using the values in another file as an input and redirect the file edit into another file

So basically I've a file that contains the below Data.txt <IP Address1>, 10, 23, <GW IP1> FINAL INPUT.45.324 <IP Address2>, 40, 33, <GW IP2> Another file that has values for ...
2
votes
0answers
92 views

Get the path of song playing in VLC using python script

I am trying to get the path of song playing in VLC using python script. I have already find out the Process ID of vlc using pgrep -x vlc And I can also display the all file descriptors of vlc ...
2
votes
0answers
646 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 ...
2
votes
1answer
128 views

How can I sort blocks of data of varying length on a field in each block

I have an RDF file with blocks of data of varying number of lines delineated by < and />. Within each block, there is a field identified by name="some name". I need to sort the blocks on the ...

1
2 3 4 5
13