Questions tagged [scripts]
A script is a program or sequence of instructions written in a plain text file. The script interpreter (for example Bash, Python, Perl etc.) reads the file and carries out the instructions as if they had been entered at the command prompt. Use this tag for all questions related to creating, troubleshooting and running scripts.
6,699
questions
3
votes
1
answer
2k
views
Shell script to check url
I am trying to write a shell script to check for the existence of a particular directory in a particular domain name. For example, I have a web site named www.example.com. I want to check whether the ...
3
votes
4
answers
5k
views
using sed replace the new line with character
I am using sed to remove the new line and replace with <br> but I am not able to get the desired output.
I wrote:
find . -name $1 -print0 | xargs -0 sed -i '' -e 's|\n|ABC|g'
...but this ...
3
votes
3
answers
3k
views
How to activate script on laptop from smartphone?
I want to run a linux script on my laptop remotely from my smartphone (iPhone, namely).
For simplicity let's say the script is called myscript.sh and it is located in /root/Desktop. I am running as ...
3
votes
2
answers
278
views
Turn off colour while using script(1)
Is there a way to turn off colour while using script(1)? My script file is being filled with unnecessary information regarding colours from commands such as ls. This information is only visible when ...
3
votes
3
answers
5k
views
Nemo Custom Action (.sh script) does not execute
I created a .sh script for simple OCR-ing of screenshots that I make with Shutter.
The script looks like this (ocrFile.sh):
#!/bin/bash
convert $1 /tmp/output.pnm
cat /tmp/output.pnm | pamstretch 4 &...
3
votes
1
answer
5k
views
ffmpeg-video trim from the end of the video
I have some videos of different duration.I want to cut(remove) the last 5 seconds of all videos.Can i use 'ffmpeg' in a loop to trim the videos?please help me.
3
votes
1
answer
950
views
How to automatically execute a command in a terminal after a period without activity?
I've been looking for an option or script that executes a command after the terminal has been idle (that's no input nor output).
The closest thing I've found is setting the TMOUT=seconds variable so ...
3
votes
1
answer
2k
views
Find files and pack them using a shell script
I am trying to find all files which size is higher than $1 (parameter) and zip them using a shell script.
#!/bin/bash
find . -type f -size +$1c = $files
tar -xf $files
But I think this isn't the ...
3
votes
2
answers
3k
views
How to create (via installer script) a task that will install my bash script so it runs on DE startup?
I've been reading for the last couple hours about Upstart, .xinitrc, .xsessions, rc.local, /etc/init.d/, /etc/xdg/autostart, @reboot in crontab and so many other things that I'm totally confused!
...
3
votes
1
answer
6k
views
How to run a shell script without terminal
I have a shell command that executes a command and sends it through pipe to a python file. The python file does various checks on it and then starts processes with parameters using subprocess.Popen. ...
3
votes
1
answer
622
views
Can I use a custom shell with upstart script stanza?
I'm writing a few daemons implemented in pure shell script and would like to use zsh(powerful substitutions, modules with socket/tcp handling, etc) instead of the default /bin/sh. Can I tell the '...
3
votes
1
answer
276
views
awk quoting program text
I just came across a gotcha in awk, and I would like to know if anyone can explain to me why this happens.
The following 2 lines behave differently if I run:
# grep -Rl BASE_DIR --exclude-dir=.svn * ...
3
votes
3
answers
2k
views
How do I run a simple Zenity script after disconnecting from WiFi?
I am running Kubuntu 12.10 64bit. I am trying to get a bash script to execute when I am disconnected from the network. I created a file in the folder /etc/network/if-down.d/ called test which has a ...
3
votes
1
answer
814
views
How to emulate pressing the Close button from a script?
I wanted Thunderbird to stay in the Background to notify me of incoming mails.
After a bit of searching, I found this post.
How to keep Thunderbird and Pidgin running on background?
The solution is ...
3
votes
2
answers
26k
views
How to start Teamviewer or any program before login [duplicate]
Teamviewer is a remote desktop application, it doesn't have to be this one, I'd be interested to know the following for any remote desktop application like VNC or RDP.
I added a "Startup script" to ...
3
votes
1
answer
956
views
Script to periodically open a file at certain intervals?
I would like to write a script that would open a excel file periodically after certain intervals. How do I do it?
3
votes
1
answer
983
views
Scripts slowing boot
Inspired by the "How fast" video, I've recently been trying to speed up my boot up as much as possible.
I've been reading many forums on different approaches but recently hit a wall with a ...
3
votes
1
answer
597
views
correct syntax to compare field with awk
First I aplogize for this idiot question .
I want to print a field if he is equals to a value .
The problem is that I'm using a non default field sperator and I didn't understand how to make it work ...
3
votes
2
answers
7k
views
How to emulate Fn (function key) keypress in xte
xte is part of the xautomation package. After hours of man page reading and looking for documentation or working examples, I still cannot get xte to emulate a Fn-F7 keypress.
xte 'keydown Meta_L' '...
3
votes
2
answers
465
views
Startup script for starting applications in certain workspaces and positions
Since Ubuntu 11.04 has removed the session save feature, is it possible to write a script to open certain applications in specified workspaces and set their position? Please provide an example (for ...
3
votes
1
answer
586
views
Off-line Repository and software removal
I read up on the process here and came up with this script:
for i in `ls -1 /var/cache/apt/archives` ; do sudo cp /var/cache/apt/archives/$i /home/jj/Documents/Repository ; done
and to re-install:
...
3
votes
1
answer
309
views
How can I get pre-canned scripts for perf script?
man 1 perf-script says that there are pre-canned scripts available with perf script -l, but when I invoke the command it outputs
open(/usr/libexec/perf-core/scripts) failed.
Check "PERF_EXEC_PATH&...
3
votes
1
answer
1k
views
Run script from Nautilus without opening terminal
I have some Python scripts that provides a UI using GTK (ie. it's not a terminal application). In Ubuntu 21.04, double-clicking in Nautilus will provide me the option to run them with or without a ...
3
votes
2
answers
1k
views
How to get a random number within a range in command line?
I need to generate random phone numbers in some curl commands across this thread about getting random numbers in the command line and I'm wondering how I can do this with a certain number range. The ...
3
votes
1
answer
250
views
Keep executed command in its tab (bash script)
I have a bash script that starts a terminal window with multiple tabs and executes a command in each of the tabs similar to this (and titles aren't supported, I know):
#!/bin/bash
title1="foo"
...
3
votes
1
answer
2k
views
Execute a shell script without `./` [duplicate]
I'm learning how to create shell scripts on UNIX for a college class. The textbook says I should just be able to type the filename in my terminal and it should run, but so far I haven't been able to ...
3
votes
1
answer
1k
views
Scripting the hiding of username on login screen (18.04)
I have a script to set up an ubuntu workstation with standard settings. One of the things it did on 16.04 was hide the usernames from the login screen.
Moving to 18.04 and I am having some ...
3
votes
1
answer
934
views
Does moving or renaming a executable file (in particular a Windows executable under Wine) impact its running while it is being run?
In Ubuntu,
when running an executable file or a script file, if I move or rename the file, will the running be impacted?
when running a Windows executable (e.g. PDFXCview.exe) under wine, will ...
3
votes
1
answer
2k
views
how can I add options to the right-click drop down menu in gnome?
GNOME Shell 3.26.2 | Ubuntu 17.10 | Bash 4.4.12
How can I add options to the right-click drop down menu in GNOME GUI? I want to place an item in the mouse right-click menu that will do echo "$...
3
votes
1
answer
31k
views
How to Fix Could not open input file in php CLI 7.0
How to run php cli right in Ubuntu 16.04?
When I enter the command php file.php always out the error
Could not open input file: file.php
How can I fix it?
3
votes
2
answers
1k
views
Track logins made via non-interactive shells
This is in reference to this question.
I wanted to log everytime someone logged in via ansible.
I put my script in ~/.bash_profile file. Here is the script,
#!/bin/bash
now=$(date +"%T")
echo "$...
3
votes
2
answers
1k
views
Type in gedit using xdotool in a script
I want to type a character in a shell and have xdotool send that character's signal to gedit, so that character will be typed in gedit.
I have written this script:
#!/bin/bash
gedit -s &
GEDPID=$...
3
votes
1
answer
1k
views
Combining several youtube-dl commands into one script
It was recommended to me by a user on here that I make a post asking how I can combine several youtube-dl downloads into on single script to be run. I'm downloading lots of youtube channels and ...
3
votes
2
answers
567
views
!x not found - bash script
I made a simple bash script to run a range of commands in your history, but it's not working.
read -p "control + c to cancel"
for i in $(seq $1 $2) ...
3
votes
1
answer
935
views
Simple GUI for various bash command
I am trying to create a very simple bash script with a GUI. I want it to bring up a dialog where the user can use the arrow keys to select a function, it will complete it and then return to the menu.
...
3
votes
1
answer
1k
views
This command works in the terminal, but not in a shell script
I have a command that I would like to run from a shell script:
LD_PRELOAD='/usr/$LIB/libstdc++.so.6' DISPLAY=:0 steam
This command is necessary to run Steam correctly on my system. If I try to run ...
3
votes
1
answer
960
views
How to make a script for touchscreen to run after resume?
I am using Ubuntu 16.04 LTS on my ASUS TP200SA which is a 2in1 laptop. I have recently noticed a bug about touchscreen, whenever I put the system on sleep and wake it up, touchscreen doesn't work. ...
3
votes
2
answers
2k
views
natural-sounding-text-to-speech
Firstly I know this question has been asked,
Natural Sounding Text to Speech?
I'm after some sort of text to speech engine, but to convert a full ebook / text. Simply put I no longer get enough time ...
3
votes
1
answer
1k
views
How to run multiple scripts in remote machine
I have to remotely connect to a gateway (working on Linux platform), inside which I have couple of executable files (signingModule.sh and taxModule.sh).
Now I want to write one script in my desktop ...
3
votes
1
answer
649
views
Script on reboot
So, I programmed a simple script to alert on slack whenever the server is rebooted.
What I did:
In /etc/rc6.d/R99reboot-slack: (I tried with R01reboot-slack)
#!/bin/sh
/scr/msg.sh "Server restarting.....
3
votes
1
answer
827
views
Script to convert .wma to .mp3 command not found [duplicate]
I am using a script called conv-script that I found on AskUbuntu here. It looks like this
#!/bin/sh
readarray -t files < wma-files.txt
for file in "${files[@]}"; do
out=${file%.wma}.mp3
...
3
votes
1
answer
1k
views
Launcher icon (to start a script) keeps blinking and is unresponsive for seven seconds, how can I solve it?
I have a script, which I start from the Unity Launcher. When I click on the icon, my script starts successfully.
While the script only takes a split second to run, the launcher icon blinks for about ...
3
votes
1
answer
850
views
Running bash script in detached screen
I could use a little help on this one. I am a novice scripter at best. I am trying to write a bash script to connect to my multiple openvpn sites. I am trying to write the script to open in a ...
3
votes
1
answer
5k
views
proper syntax for grep: search a string, copy two rows above and transpose
Am new (2 days old) to Linux and grep and am stuck here.
Scenario. I have data lasting more than 10yrs which I have been doing manually until I came across grep. The folders are of form /yyyy/mm/dd i....
3
votes
2
answers
92
views
Run 1 function of bash script
Is it possible to run only a part of the bash script on startup of ubuntu server?
if so how can I achieve this?
3
votes
1
answer
766
views
parse webpage upto n levels using wget
I am trying to extract URLS from a webpage up to user defined n levels using wget. I tried this
wget -r -l$2 --reject=gif -O out.html www.google.com | sed -n 's/.*href="\([^"]*\).*/\1/p'` "
It is ...
3
votes
1
answer
95
views
What is a (reasonably) secure and automated way to backup my mysql database using (any) free cloud/online services?
I have a mysql database that I use for personal devlopment. I would like to back-it up online using any free (in cost) online storage. (dropbox, google-drive etc...)
I am assuming a shell script ...
3
votes
2
answers
3k
views
How to execute a custom script when Internet reconnects?
My Internet gets disconnected every now and then. I'd like to run a Bash script every time the Internet reconnects.
The script is quite simple:
#!/bin/bash
mplayer /home/user/sound.mp3
It's placed ...
3
votes
1
answer
2k
views
Execute Script when Android Phone is connected to specified/selected USB Port
I´m having some trouble with my udev rule. At the moment, I had my udev rule setup to execute a script whenever a Android phone is connected to any USB port on the computer. But I don´t want the ...
3
votes
1
answer
765
views
Ubuntu Touch: how to create a launcher to start a shell script?
On my bq Aquaris E4.5 I want to create a launcher button for the App Scope to start a shell script. Is there an easy way to create such a launcher?