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.

Filter by
Sorted by
Tagged with
1
vote
2answers
39 views

Shell script on “read” accept via both enter key and tab key

in shell script when you have the following : read my_variable Enter is the key that saves your input. is there a way to make Tab accomplish the same as Enter without removing Enter's functionality?...
1
vote
1answer
28 views

Is it possible to have mutliple concurrent coprocesses?

The intent of the test script1 below is to start an "outer" coprocess (running seq 3), read from this coprocess in a while-loop, and for each line read, print a line identifying the current iteration ...
0
votes
0answers
16 views

can't run sh script from crontab [duplicate]

my script: #!/bin/sh PATH=$PATH:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin if pgrep -x "firefox" >/dev/null then return else firefox & fi my crontab: * * * * * /home/...
2
votes
2answers
74 views

Wildcards not interpreted by shell script when used with output redirection

Say I have two scripts: script1.sh: #!/bin/bash version=2.6 log_file="$HOME/log-file-version-$version.log" touch $log_file &>/dev/null echo "log to my log file from script 1" >> $HOME/...
0
votes
1answer
1k views

How to copy files to the timestamp generated directory?

Hello I am trying to copy all files from Documents directory to the backup directory that has a timestamp. So I have created a directory called bk$( the time stamp of the directory) and I am trying to ...
0
votes
1answer
1k views

bash script for cdo command to run it on different files

I am new in UNIX and I want to apply the CDO (Climate Data Operator) "remapbil" command in order to transform the grid (from a projection to geographical coordinate system). it works perfectly fine ...
-2
votes
0answers
33 views

need to print all /etc/*.conf one after another and redirect into a .txt file in bash (peferable)

i'm a linux student and in a intership of a IT org; also I'm follower of this forum, I stuck in a requirement and need assistance. need to develop a script in bash/ksh; the script whenever will run, ...
1
vote
1answer
21 views

How to debug the script in logs for shell script? [duplicate]

I am having a script which i have set in the debug mode: set -x #!/bin/sh ALLCIRCLS="/var/tmp/release/ALLCIRCLS.txt" NONRBTIPS="/var/tmp/release/NONRBTIP.txt" RBTIPS="/var/tmp/release/RBTIPS.txt" ...
0
votes
1answer
825 views

permission needed for Python to access USB drive?

I got this Python script that reads media files from USB stick. It used to run fine, today it keeps giving me OS Error: [Errno 13] Permission denied: media/myName/usbName when the script runs the ...
1
vote
2answers
977 views

Stop bash script with any key

I'm writing a custom gnome-terminal profile which I want to stop with any key I choose. After pressing the key, my intention is to complete all my commands at that moment and start su. I've tried ...
1
vote
1answer
19 views

How to search and replace for multiple words in one shot

I need to search and replace multiple words. For example, in my file, I want to search for any name of week days that appears with a comma after it: Sat, or Sun, or Mon, or Tue, or Wed, or Thur, or ...
1
vote
0answers
22 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 ...
0
votes
1answer
24 views

Run scripts at logout

Sometimes I ssh into a box, and run some script that makes a change to the system. I want to undo this change when my session ends, either explicitly (e.g., via exit from the logout shell) or ...
0
votes
0answers
24 views

Getting error while running the shell script

CURRTIME=$(perl -e ' print time(), "\n"') FILETIME=$(cat timestamp.txt ) TIMEDIFF=$(($CURRTIME - $FILETIME)) I need to add 1 second to FILETIME variable, even if there is no entry in timestamp.txt, ...
1
vote
1answer
35 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 ...
0
votes
1answer
1k views

Cannot stat error?

Running a "restore" script which moves a file previously deleted (moved to a trashbin folder) back to where it came from. Running the secondary script I receive this error... "mv: cannot stat `test': ...
0
votes
0answers
17 views

suming numbers one by one contained in a file until certain number and printing then

I have a file called temp6.dat with a list of numbers in a column. I want to sum this numbers one by one until the result is >=80 or <=85 and print the numbers from this list starting with the ...
-3
votes
0answers
27 views

Which project I should do [closed]

Which Project can I do during my 15 day vocation In shell scripting and in combination with python for Debian distribution
0
votes
1answer
982 views

Python script: wait until job in tmux session has completed

I am trying to continuously run a python script with random parameters from another python script, where each run is in its own tmux session. A very simplified overview of what I'm trying to do goes ...
2
votes
1answer
27 views

Is there a way to restart acpid on reboot?

I've installed a package called thinkpad-scripts. Simply put its a bunch of scripts that activate various functionalities on thinkpad devices on linux that wouldn't work out of the box on fresh ...
1
vote
1answer
58 views

System service “Error: Unable to initialize GTK+, is DISPLAY set properly?”

/home/matthew/@/Sync/FreeFileSync "/home/matthew/@/Sync/Backup.ffs_batch" If I manually run the above, it works, but it doesn't if I run it via the following service: matthew@matthew-pc:~$ cat /lib/...
-1
votes
1answer
28 views

Bash Logical operation into variable

Easy one for you. Can we do something like this in Bash, without using IF statements? a=0 b=0 c=1 result= [ a || b || c ] # result of binary operation should be 1 Is this possible?
0
votes
2answers
1k views

Run this PHP file via Cron Job

Here is the script: <?php //Create back files? define('CREATE_BACKUPS', FALSE); if (!is_dir($argv[1])) { echo "You must enter a valid path such as /home/apresv/public_html or apresv/...
0
votes
0answers
9 views

Take similarly named fastq files on a folder and amke them input for an script(on pairs)

I have a set of files named like this inside a folder: AM11_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
4answers
38 views

Converting for loops on script that is called by another script into GNU parallel commands

Currently I have the following script for using the HaploTypeCaller program on my Unix system on a repeatable environment I created: #!/bin/bash #parallel call SNPs with chromosomes by GATK for i in ...
1
vote
1answer
25 views

How to get list packages installed in debian instance as an offline install for another machine

I have put together a debian instance with apt as the package manager that has many packages installed. I would like to install these same packages on another system that does not have an internet ...
42
votes
8answers
105k views

Script to change current directory (cd, pwd)

I want to run a script to simply change the current working directory: #!/bin/bash cd web/www/project But, after I run it, the current pwd remains unchanged! How can I do that?
0
votes
3answers
33 views

Replace and increment a line in bash

How can I read, increment and replace a value in a file? foo="val" ver="1.2.0001" ... Now I would like to increment the "0001" to 0002".
0
votes
1answer
2k views

Bash script in Linux [duplicate]

I want to login to a remote system in ubuntu using a script file which will be executed in my system . The script contains the following commands #!/bin/bash echo 'systemPwd' | ssh myMachine@192.168....
0
votes
1answer
41 views

crontab and scp file transfer via script

I have a script that exports logs from log management server and send those exports to the archiver server. When I run this script manually, it complete it's task without any problem. It download ...
17
votes
2answers
2k views

Ask for a password in POSIX-compliant shell?

When I want to ask for a password in a bash script, I do that : read -s ...but when I run bash in POSIX mode, with sh, the -s option is rejected: $ read -s sh: 1: read: Illegal option -s How do I ...
1
vote
1answer
40 views

How do I get the amount of internet data used throughout the day?

I need to set a cap to my internet usage and manage data usage to download things programmatically based on the amount of data I have consumed. Is there a way to find out how much internet data I ...
41
votes
7answers
93k views

File extensions for unix shell scripts [closed]

On wikipedia, the article for .sh says: For the .sh file extension type, see Bourne shell. How about other unix shells? I know that the shebang is used inside the file to indicate an ...
41
votes
6answers
31k views

Autohotkey Equivalent?

Is there an equivalent product/method for AutoHotkey. For those that don't know, its a product that allows you to program your mouse movements and keyboard. This allows me to "macro" certain functions ...
0
votes
1answer
1k views

I am trying to run an archive shell script from BODS. The archive script is stored in an FTP server. I get no file or directory found

Below is my shell script: export PATH=/home/dsadm/bin/lftp2/bin:$PATH Filename_Train_Type="Training-session-type*.xls" lftp -u xxxxxxx<< EOF lcd /home/dsadm/BIIT/Scripts/ cd /TDB_VESI/IN/...
-1
votes
1answer
37 views

Choosing best directories to compress and save disk space

What's the best way to estimate the compression level that can be achieved for a directory without storing the compressed files? I have a large amount of directories and sub-directories with files ...
7
votes
2answers
22k views

Scripteable GPT partitions using parted

I am partitioning eMMC using following commands in the script, parted /dev/mmcblk0 --script mklabel gpt parted /dev/mmcblk0 --script mkpart primary ext4 32MB 132MB parted /dev/mmcblk0 --script mkpart ...
2
votes
2answers
68 views

Sorting and editing a text file to output a new file

There are few stages to this problem. I have the following data and I want to sort it first on column 2 the 5 then 1. Then I would like to combine columns 5 and 6 together with a deliminator. When ...
0
votes
2answers
1k views

Cron tab to run a java file

I'm having issues getting a cron tab to run a java file every 5 minutes. I have tried to create an executable script to see if that is what's needed: My script and java file are both stored in /usr/...
1
vote
1answer
18 views

Permission Denied with running custom script that has correct permissions

I have downloaded script called 'linkhandler' in my /bin/ folder, whose content is below. I have given the file permissions, this is the output from ls -lah: -rwxrwxrwx 1 root 861 Jul 8 13:12 ...
-1
votes
2answers
49 views

Renaming file from a script? [duplicate]

I am creating a script which would enable me do something in a shorter amount of time. Is there a way that I can rename a file automatically from: WDMyCloud_plexmediaserver_1.16.1.1291.bin(07082019)' ...
13
votes
7answers
11k views

How to remove multiple blank lines from a file?

I have some text-files I use to take notes in - just plain text, usually just using cat >> file. Occasionally I use a blank line or two (just return - the new-line character) to specify a new ...
1
vote
0answers
48 views

Running hashcat periodically [closed]

How can I run hashcat to find md5-hashes? My Ubuntu shuts down the computation if the GPU has too high temperature. Is there way to write a script that if temperature is too high, hashcat saves ...
0
votes
0answers
29 views

How to portably test for a SIGPIPE failure

In a bash script, I have a pipeline of this form /bin/find ... | grep --quiet --max-count=1 . Basically, I am just testing, yes/no, whether /bin/find found anything. Therefore, if /bin/find fails ...
1
vote
1answer
19 views

How to avoid prompts with install linux-image-extra-virtual

When trying to install linux-image-extra-virtual I get the usual prompt about /boot/grub/menu.lst being modified: What would you like to do about it ? Your options are: install the package ...
2
votes
1answer
469 views

Integration of afuse user-level automounter with sshfs as a systemd service spawned from login for local users

To facilitate working with remote files, I setup afuse with sshfs to run from .bashrc of local users. It works, after bash init all remote trees from ~/.ssh/config/ are mounted on-demand under ~/scp/, ...
1
vote
1answer
1k views

Save cached video on firefox?

I found a script on the internet that allows me to save cached flash files. https://github.com/janosgyerik/shellscripts/blob/master/bash/save-flash-linux.sh This would allow me to run the command ...
0
votes
0answers
37 views

Why can't execute ls or cp commands with a variable as an argument [duplicate]

I am debugging a bash script. It executes cp and mv commands in the script when a variable containing a path is used as the argument to the command. I have duplicated it in the terminal as follows: ...
0
votes
3answers
8k views

Run a script in a new terminal window

I am looking to run a script that is separate from my parent script in another terminal window while keeping the current window usable. The reasoning behind this is I wish to allow the user to be ...
3
votes
3answers
12k views

Change motd value in UNIX Operating System

I need to change the value of MOTD using a script but I do not know how I should start. Am attaching sample MOTD.