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.

430 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
10
votes
2answers
434 views

Replace current process by its coprocess/child

I have a program P that expects to receive "Hello" and output "Why?" before providing a feature. This feature is used by other programs that are not aware that it is common courtesy to start a ...
8
votes
2answers
1k views

Whenever ansible makes changes to sshd in CentOS7 a random future play cannot connect

This has been an irritating enough problem now that I thought I would finally ask the community at large what a possible solution might be. It's even more irritating that I seem to be the only one ...
6
votes
1answer
534 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 ...
5
votes
1answer
127 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
225 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
1answer
541 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! ...
4
votes
1answer
1k views

Purpose of the autostart-scripts directory

A user can place .desktop files in his ~/.config/autostart/ directory to run a script on login (session start) in Gnome, or indeed any Freedesktop-compliant environment. But, on my openSUSE Leap 42.2 ...
4
votes
1answer
254 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
188 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
868 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/...
4
votes
1answer
2k 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. ...
4
votes
1answer
437 views

vim auto complete custom list

I had these two questions about this function " how do I load a file into a list here? " set some variable func! CustomComplete() " and then read the variable here so that b:list = a \n split ...
3
votes
1answer
533 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
286 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
304 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
926 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
902 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
2answers
654 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
2k 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
0answers
128 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 ...
3
votes
3answers
75 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
126 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
81 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
61 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
949 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
421 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
1k 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
1answer
48 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 ...
2
votes
0answers
62 views

Copying contents of a folder via SCP results in `scp: error: unexpected filename: .`

I was using a script to copy the contents of a folder via SCP, without copying the folder itself. Something like this: scp -i id_rsa -P "$PORT" -r "$HOST:/folder1/folder2/." "backup" (I'm not able ...
2
votes
0answers
46 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
1answer
147 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 --...
2
votes
0answers
152 views

how to output html to a file with xmllint?

How do I get xmllint to output to a file? thufir@dur:~/xmllint$ thufir@dur:~/xmllint$ xmllint --html http://www.skynet.be/nieuws-sport/weer/mijn-weer?cityId=6450 --xpath '//div[@class = "tides"]' - ...
2
votes
2answers
26 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
39 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
1answer
48 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 ...
2
votes
0answers
52 views

script-like pty recording

dear unix wizards: I have wrestled with the unix script program for a while, but to no avail. It may be the wrong program altogether, but googling is hard, because script usually just means sh or ...
2
votes
0answers
487 views

Automation of ssh change password on 1-st login (no expect)

My account was copied from 1 to a big number of hosts. On every host on 1-st login I get: WARNING: Your password has expired. You must change your password now and login again! Changing password for ...
2
votes
0answers
43 views

Prompt user with email when Disk Usage is over 200GB

find . -printf "%u %s\n" | awk '{user[$1]+=$2}; END{ for( i in user) print i " " user[i]}' Hi I have been using the above CMDline to look for each user's disk usage information. I would like to know ...
2
votes
1answer
624 views

Non-interactive & non-login shell environment?

I'm trying to understand non-interactive & non-login shells and having a hard time conceptualize the process a non-interactive & non-login shell goes through to start up. The way I ...
2
votes
0answers
114 views

Flicker-free OSD display of system information

I'm trying to get a small script running to display information about CPU and GPU usage. The script is complete and outputs information in the following format CPU 2% 37C GPU 0% 56C ...
2
votes
0answers
358 views

Automating Google image search

I am using a raspberry Pi at the moment and I would like to acheive the following. Every hour an automated Google Image search of a specific predefined term. The image is then downloaded to the Pi ...
2
votes
0answers
106 views

AppleScript dialog and repeated `say' command not working in OS X cronjob

I've got a script in OS X that looks in a given directory for the file with the most recent mtime, sees if it's (past) a certain size, and, if so, creates an AppleScript dialog box + repeats an ...
2
votes
0answers
828 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 ...
2
votes
1answer
552 views

Bash script works via terminal but not via main menu

When I run a bash script from terminal or nautilus, it works properly, but when I run it via gnome's 'Main Menu', it returns an error. read -p "" -n1 selection This is the line, that return the ...
2
votes
1answer
52 views

String substitution in large file

I have two TSV (tab separated value) files -- file_A.txt and file_B.txt file_A.txt contains two columns -- A_ID, A_Name file_B.txt contains 4 columns -- B_ID1, B_Name1, B_ID2, B_Name2 Need to go ...
2
votes
1answer
300 views

Bash completion extra space when adding file directory

I have a script for extending bash-completion for certain commands. If I type command1 and do a tab, it should auto-complete with a file directory (and the files). It works fine expect for one ...
2
votes
0answers
279 views

Change existing dovecot maildir installation from m-UTF7 charset to UTF8 to avoid breaking TAB

In an existing dovecot installation with many pre-existing folders using regional characters I would like to change m-UTF7 (.&AMk-l&AOk-ments envoy&AOk-s) foldernames to UTF8 (.Éléments ...
2
votes
1answer
141 views

Producing the next available filename for a pattern (02-output.log etc)

I can use mktemp(1) within a shell script to make a temporary file in a directory with a suitable suffix & prefix. Is there a command that, given a pattern (e.g. NN-output.log) will look for 01-...
2
votes
0answers
430 views

killall doesn't work if I call it from a script

I'm starting a tcpdump inside a script and I also kill it from the same script. So I'm currently using the killall command for this: The script gets executed from an udev rule: This is the section, ...
2
votes
0answers
666 views

Slow script execution

I have a strange problem... My script: #!/bin/bash SECONDS=0 lock_file=/tmp/$0.lock [ -e $lock_file ] && exit touch $lock_file echo "<<<db2_hadr_check>>>" instances=( ...