Questions tagged [shell-script]
A shell script is a script written for the shell, or command line interpreter, of an operating system.
353
questions with no upvoted or accepted answers
4
votes
0
answers
1k
views
OS X: Terminal command to check a file's default application
I'm writing a script which opens some files, in their default applications, via the open command. Before I actually open a file, though, I'd like to check which application is listed as its default ...
4
votes
0
answers
538
views
Run program on kde logout
I have created a backup script and I want to run it in a terminal window (to view the progress) when I logout from kde. I used the autostart feature and that works but I'm unable to show a terminal ...
3
votes
0
answers
165
views
Is there a good way to write a shell script compatible with both bash and zsh that addresses array elements?
The fact that bash is 0-indexed and zsh is 1-indexed can cause problems. For example the following will work as intended with bash, but not zsh (PS I am aware that I don't NEED to use an array for ...
3
votes
1
answer
1k
views
How can I read a password once, then pass it to the cryptsetup command repeatedly?
When i execute the cryptsetup command, it responds with a command line output - "Enter any existing passphrase:".
I want to read this from console into my script and pass the passphrase from the ...
3
votes
0
answers
371
views
Tools for converting 8-bit C1 control characters to ESC sequences?
The ECMA-48 ("ANSI escape sequences") standard describe two ways of encoding the C1 set of control codes: using 2 character ESC sequences, or alternatively, using 8-bit control characters.
Wikipedia ...
3
votes
0
answers
1k
views
Find out the real path of a file from a SUBST drive
Is it possible to find the real location of a file, knowing its location on a drive created with subst? Example:
> subst d: c:\dir\
> real_path "c:\file"
c:\file
> real_path "d:\file"
c:\dir\...
3
votes
2
answers
1k
views
Creating a hard linked differential backup (trying with rsync)
I am trying to create a script that creates both a snapshot backup and a differential backup, but with hard links instead of duplicated files. In other words:
All unchanged files between the current ...
3
votes
2
answers
91
views
opening several terminals at once
In my dev environment, I sometimes need several terminals to be open, each running its own script/ a server (rails, django, redis, mongo, consoles, etc)
How can I create some shortcut that will open ...
3
votes
0
answers
79
views
"Autoscroll" Pdfs one by one from a "play-list"/directory
Is there a way to achieve this:
open multiple .pdf from a "playlist"/given directory one by one in the same window, with auto-scrolling enabled?
(Explanation: 1st pdf opens- autoscrolls to the end- ...
3
votes
1
answer
861
views
Running commands and shell scripts in Ubuntu
I'm trying to run a shell script in Ubuntu to flash my Firefox OS phone. I've downloaded and unzipped the new version. I've launched the shell and navigated to the directory where the .sh file is.
...
2
votes
0
answers
84
views
How to quick record system audio in background on macOS?
On macOS Monterey I want to achieve what can be done on Windows with ShareX: record system audio with a global hotkey and have the audio file automatically copied to the clipboard – all in the ...
2
votes
0
answers
45
views
SFTP user login details real-time filtering
I have enabled the SFTP login log into the default logfile /var/log/syslog and tried to filter the login time of each user and insert it into the database.
But the filtering is not worked as I ...
2
votes
0
answers
284
views
xss-lock turns the screen black before running the lockscreen script
In my i3 config I have this line to lock the screen using i3lock.
exec --no-startup-id xss-lock --transfer-sleep-lock -- ~/scripts/lockscreen.sh
The script checks if I am watching YouTube or ...
2
votes
0
answers
881
views
How to pass multiple automatic reponses to user prompts between batch files using powershell?
I am trying to setup a system that allows for users to be able to format a script that in turn calls other scripts or commands that they include in this script.
On Linux I have it working using:
cat &...
2
votes
0
answers
155
views
Does tput automatically check color abilities when loading color codes?
When using tput setaf and tput sgr0, does it automatically output nothing if the session isn't tty-like or no color support is detected?
So am I fine doing this?
declare -r styleRed=$(tput setaf 1)
...
2
votes
1
answer
160
views
Cant start apache on mac like i did on windows
I have very simple task to do, since i am not expert in this field i am asking for a help.
Right now i am trying to run apache on my mac, i have windows working script and i need basically to do the ...
2
votes
1
answer
161
views
How do I get this randomised copy/paste/rename to work in my Win10 batch script?
I'm trying to force Windows 10 to change the logon/lockscreen pictures every so often with our own company ones (corporate branding).
The following directory contains the Microsoft stock images:
C:\...
2
votes
0
answers
382
views
Monitoring a log file until it is complete
I am a high school student attempting to write a script in bash that will submit jobs using the "qsub" command on a supercomputer utilizing a different number of cores. This script will then take the ...
2
votes
2
answers
120
views
Schedule a job with at command
Hello I have written a script and I want to schedule it to run at a certain time with the at command. I also want to use an argument in order to pass the time I want in the script so it can be ...
2
votes
0
answers
173
views
Is there a way to activate/run script when disconnected from wifi hotspot?
This script works perfectly to reconnect the lost Wi-Fi signal/connection. Is there a way to auto-activate/run this script every time my Mac is disconnected from the Wi-Fi hotspot?
#!/bin/bash
...
2
votes
2
answers
538
views
Wake up a computer over Internet using another computer in the same local network
I have two Arch Linux-powered computers, 'A' and 'B', connected to the Internet via the same router. I have configured and tested Wake-on-WAN on both of them. Both computers are shut down most of the ...
2
votes
1
answer
320
views
How to set different shell prompt color for each newly opened terminal
I am using Ubuntu and can manually change the bash shell prompt color to green using
export PS1="\e[0;32m[\u@\h \W]\$ \e[m"
However, I want the shell prompt color to automatically change whenever I ...
2
votes
1
answer
615
views
Merge only new entries from one xml file to another
I have 2 xml files. The 2nd file has some new entries including same entries as that of the 1st file. Examples of the 2 files are given below.
File 1
<SERVERNAME_ONE>
<Protocol>...
2
votes
2
answers
589
views
compare and calculate two variables with multiple values in shell script
I have written three hive queries in shell script for calculating debit-credit and target amounts which output below values:
debit_amount : BOI 4760545.650000 AXIS 284.49000000 SBI 87.220000000 ...
2
votes
0
answers
124
views
Mount USB-Device (Printer) per Script on Ubuntu 14.04 Virtual Box 4.33
We have ubuntu 14.04 with Windows7 on the Virtual Box 4.33 running. As the USB-Printer is mounted at the host or the guest and there seems to be no solution to make it on both available, now my ...
2
votes
1
answer
1k
views
How to view two dialog boxes on the linux console, running on the same time?
I want to view on the Linux console two dialog windows on the same time.
I want a window that views the progress BAR, and the a second tailbox that view the logs are running.
The problem is that the ...
2
votes
1
answer
108
views
Using bash script to select/view only specific data from logfile
My NAS creates a logfile in the format below:
<30>1 2014-07-21T05:02:10+02:00 ABC-NAS qlogd 6432 - - qlogd[6432]: event log: Users: Glacier, Source IP: 127.0.0.1, Computer name: localhost, ...
2
votes
1
answer
367
views
Chrome OS sudo startunity app
I am running crouton unity on a Samsung chrome-book.
How do i automate a shell script to start unity into a chrome OS app that I can place on the chrome shelf next to the other chrome apps?
i want ...
2
votes
1
answer
3k
views
xargs in shell script
I want to group jpeg images by odd number and even number.
So I did like following:
$ mkdir odd
$ mkdir even
$ find . -regextype posix-egrep -regex ".*[13579].jpg$" -print0 | xargs -i -0 mv {} odd/
$ ...
2
votes
2
answers
198
views
UNIX-Shell Scripting
While executing the below script, I'm getting an error:
Syntax error at line 1 : `(' is not expected.
sudo su - user1 -c "cd $HOME ; tar -cvf $HOME/mine.tar `cat /tmp/$LOGNAME/List` "
where List ...
2
votes
1
answer
639
views
how to remove "downloading" or 0% complete torrents in rtorrent using bash script?
I have 10K torrents and 7K of them are going too slow. I would like to remove them but the rutorrent and rtorrent interface is unusably slow. I noticed that the info about rtorrent is kept in .session ...
2
votes
1
answer
934
views
Passing Return Key via Shell Script
I'm using phpseclib to run a shell script on my server at a given interval. That script involves using nohup. For whatever reason, if there isn't a user ready to send SIGINT or a return to nohup once ...
2
votes
1
answer
100
views
Automating the installation using SSH
I am running a bash script from a remote host to run a binary file which installs 64 bit JDK 6 update 29 on multiple VMs across the Environment.
It is installing the file but, at the last line i have ...
1
vote
0
answers
18
views
Pathname or word too long in Cshell
I am using cshell. And I know that there is a limit of 1024 character while setting path. But I have many path variables which I need to set. So, it is exceeding 1024 characters and I am getting an ...
1
vote
0
answers
40
views
Zsh handling of substring changed?
I have over a thousand directories holding MP3 files and text. I work on one directory each day, assisted by zsh scripts. I mostly use zsh on command line and in scripts. The paths are in the form ...
1
vote
0
answers
38
views
Grub script how to remove menuentries
I made a grub script to detect bootable disks and show them on grub menu. It is working but I want to put a rescan button and to make that first I need to remove old menuentries. How can I do?
My ...
1
vote
0
answers
1k
views
Termux can't run shell script
As stated in the topic above, I am trying to configure a hardware using shell script which is downloaded from the official website of Orange Pi. Am using termux as the medium to run the shell script ...
1
vote
0
answers
178
views
Source multiple files in background/parallel (ZSH)
For various reasons I would like to be able to source a series of files in background and wait for them all to finish:
source ./my_file_1.sh &
source ./my_file_2.sh &
...
# etc
wait
But, ...
1
vote
1
answer
246
views
Batch rename movie folder(s) to movie file inside of folder?
I would like to rename my movie folder names to match the movie file name inside the movie folder. The movie files have the right names but the folders do not.
I've found batch file rename options for ...
1
vote
0
answers
155
views
ssh.localhost.run tunnel configuration command on Shell
I am currently writing a shell script for automating.
Manually, I will create a new session ssh.localhost.run by input Tunnel information on PuTTY like this
Full steps:
host name "ssh.localhost....
1
vote
0
answers
177
views
Execute a command after matching a specific rule of iptables
Is it possible or is there any way from which a bash script can be executed using iptables?
Like I wanted to execute a bash script if incoming traffic on a udp port crosses 1000pps
I tried searching ...
1
vote
0
answers
624
views
FFMPEG - merge (NOT concatenate) multiple sets of 2 videos in for loop
I have a folder A with mp4 audio.
Folder B has mp4 video.
The filenames match, expect that they are in different folders.
These are movie files that when they were downloaded came in two separate ...
1
vote
1
answer
397
views
Backup with all metadata preserved but converting file content into zeros (or empty sparse file)
I want to make backups of a directory, everything the same as original files, only except for file content converting to all zeros (sparse files), and also keep the same file size. So for example, I ...
1
vote
0
answers
853
views
Start-Process elevated powershell & send a variable to be used when running elevated script
When this scirpt is executed(non-elevated) this script asks password and maps onedrive and then it automatically launch powershell(elevated) and asks again password for bitlocker.
If single password ...
1
vote
1
answer
969
views
How to find the first and last occurrence of date field in a log file in linux?
log_file:
2021-08-29 23:25:46,398 IST INFO :......mailslot_create: creating socket for querying route
2021-08-29 23:25:46,398 IST INFO :.....mailbox_register: no mailbox necessary for forward
...
1
vote
0
answers
250
views
Simulate "Enter" keypress after successfully making connection using Netcat on Raspberry Pi
I have an issue with using Netcat on Raspberry Pi terminal to output data after making a connection. The issue is that when I run this command, after it is succeeded, 5 seconds pass, and the ...
1
vote
0
answers
58
views
Cron script with xtrace gives false errors
I'm running a shell script through cron on my Raspberry Pi (running Raspbian). Since it's a backup script, it sometimes can run for a long time (if I've added a lot of photos, for instance), and I don'...
1
vote
1
answer
332
views
Any way of starting and stopping Google Backup and Sync by script/program?
NB Please note that this is a non-Postill question. It is intended for people who understand something about Google Backup and Sync, and scripting, and wish to answer a question about it.
The problem ...
1
vote
1
answer
487
views
Executing script only on terminal startup with tmux
I have configured my Gnome terminal on Linux Mint 18.3 to always start tmux by default by adding a couple of lines to my ~/.bashrc. This works extremely well, except that I also run another script ...
1
vote
1
answer
359
views
Elementary OS: How to create a clickable shellscript
I am trying to make a shellscript clickable in a folder?
What I want is for the user to be able to click/double-click a shellscript in Files via the GUI and then have this shellscript open and run ...