The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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.

454 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
2answers
199 views

Renaming a list of files from a text file

I have a folder containing these list of files. lesson1.mp4 lesson2.mp4 lesson3.mp4 lesson4.mp4 I`m trying to rename this files based on contents of "rename.txt" 1. Introduction to the React ...
0
votes
0answers
351 views

scripting with telnet and tee

with #!/bin/bash telnet ipaddr port & i=1 while [ "$i" -lt 3 ] do (( i += 1 )) sleep 10 done result: Trying ipaddr... Connected to ipaddr. Escape character is '^]'. ...
0
votes
1answer
58 views

if statement with two column output

I do have an output as shown below. My plan is to get the first column and do a if statement greater than n value it will get the IP second column and drop the connection. cat file| egrep "invalid|...
0
votes
1answer
30 views

Script to copy a file into another with changed values each time

File1 has some content and suppose it is : as 1 df 1 qw 1 er 1 ty 1 Now I need to add File1 appended into File2 60 times with each time the number incremented by 1 every time.
0
votes
1answer
98 views

How can I automate adding a new user, using an existing user's groups?

Raspberry pi comes with a default user account that is added to multiple groups: username@hostname:~ $ groups pi pi : pi adm dialout cdrom sudo audio video plugdev games users input netdev spi i2c ...
0
votes
1answer
54 views

Variables from specific parts of an Text File as variable for further usage in shell script

We have an HaProxy setup in our company, and this works with SSL (certbot / crt-list.txt). We want an automated task that reads the file crt-list.txt and takes out the Domain Name as a variable. What ...
0
votes
0answers
140 views

Safely granting permission to a Perl script to change users and groups of filed downloaded with rsync

I've got a Perl script which is a wrapper to a Net::OpenSSH object which I use to rsync a remote server's files to my local machine. I'm using the archive, -a, option to preserve file ownership and ...
0
votes
0answers
174 views

How to fill empty cells of a csv file with 0 and remove cells where there is no header?

I want to import a really disgusting csv file with empty cells and cells without headers to Cassandra database. I tried The following command from linuxconfig.org : #!/bin/bash for i in $( seq 1 2);...
0
votes
1answer
2k 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 ...
0
votes
0answers
343 views

Wait to Mount Until Process Not Busy

I am writing/reading to an SSD over NVMe. I would like to unmounts the SSD partitions and remount them after writing and before reading so as to avoid caching problems. It seems when I try to perform ...
0
votes
1answer
1k views

how to get multiple command output as variable in awk

I am trying to execute 3 command and get the output as a variable which needs some percentage calculation and display the same as the example. can this be executed as script. First command output $ ...
0
votes
2answers
806 views

How to set variable to output of a command in a bash script, without the command output showing in terminal?

Trying to run the following script: echo "Is autofs Enabled?" cmd=`systemctl is-enabled autofs` echo $cmd if [[ $cmd = "enabled" ]]; then echo "Yes autofs is enabled" elif [[ $cmd = "disabled" ]]; ...
0
votes
1answer
57 views

file-name replace using options in Linux shell scripting

I am using the below command to replace the file names in /opt/jboss/QueueStandalone/cron folder all .sh files: find /opt/jboss/QueueStandalone/cron -name '*.sh' -exec sed -i -e 's/Old-name/New-name/...
0
votes
1answer
85 views

where are codiad projects stored locally?

In Firefox I installed codiad as: where is ruby_hello actually located? (When it asked for the absolute path, I wasn't able to put in /home/thufir/... because of permission, so just typed in "...
0
votes
0answers
97 views

paplay doesn't play in genmon (Generic Monitor) script

Am I right that paplay doesn't play sounds in genmon (Generic Monitor) script? How to generate sounds in genmon script? I prepared a script for genmon plugin in my stretch debian xfce #!/bin/bash ...
0
votes
1answer
553 views

This script whiptail not working correctly

#!/bin/bash variabile = $(whiptail --title "EXALL" --menu "Inserisci il tipo di comando da eseguire" 25 78 16 \ "Apri" "per aprire un programma in background" \ "Esegui" "per aprire un programma in ...
0
votes
2answers
403 views

Find and copy with xargs doesn't work in a script

I need to find three files from a huge directory and copy them to another directory. This is what I have done: find $adir -type f \( -name "a1*" -o -name "a2*" -o -name "a3*" \) -mtime -8 | xargs cp ...
0
votes
0answers
61 views

A string from my script in the LOG file in BackupPC:?

I'm using BackupPC and I've made a script that will email me a notification every time a backup has occurred, whether it's successful or has failed. In this script, I would like to extract the last ...
0
votes
1answer
130 views

Script file set specific date

I created a script file that should run every month, but the problem is the date should look like this from - 20170701 - to - 20170801 and the the next month it should run again on this from 20170801 -...
0
votes
3answers
84 views

Run a script while working on another program

I would like to know how to open a script in a different workspace while working in another workspace. The script opens different webpages every 2 seconds and it lasts 2 minutes to open all the ...
0
votes
1answer
89 views

Extract lines from character to character in a loop

I have this line here and it works great to extract lines from a character to a second character (excluding the last line): sed -n -e '/>AB123|x2/,/>/ p' filename | sed -e '$d' > output ...
0
votes
1answer
35 views

Including custom software in Fedora ISO

I'm thinking about distributing a Fedora CD, which is basically the regular Fedora 25 installation ISO but with my own custom software added to it. I assume I can just mount the original ISO and add ...
0
votes
1answer
49 views

line at a time work progress filter for scripting

So lets say I have a script that works on groups of files, and does several different sorts of operations. Printing out a filename as it gets processed helps give an idea of how well things are going....
0
votes
2answers
42 views

Merging folders with a script

I have a list of 417 folder paths that I need to merge in a specific order so that files in them overwrite each other. I'll probably need to do it again in the future when I make changes to the folder ...
0
votes
1answer
608 views

Open URL in new firefox window not tab in a bash script

I want to open a URL in Firefox always in a new Window and not in a new tab. It is on my raspberry PI on iceweasel and I just can't find a soultion for my problem. What do I have: firefox -private-...
0
votes
1answer
594 views

Perform periodic task using BASH and watch command

I'm trying to write a BASH script with the purpose of using watch command to monitor a local git repository for changes from the remote branch and then executing a task. Let's say the script is ...
0
votes
2answers
571 views

Loop through file to obtain bash script variable

I'm working on a script to check the status of several remote MYSQL hosts by logging into the every server and recording whether the login has been successful or not. The idea is to store the login ...
0
votes
1answer
691 views

Linux script for file change email notification ( not inotify or any other utility)

I'm looking for linux script (not inotify tool or any other utilities ) which notifies me via email whenever file contents are changed. I have managed sample script via google, but i have to run it ...
0
votes
1answer
75 views

Change script to act for battery level instead of temperature

I have a script that can put the computer to sleep at a certain CPU temperature; #!/bin/bash while true; do val=$(sensors | awk '/temp1/ {print $2}') max=$(echo "+82.0") if [...
0
votes
3answers
84 views

How to create a script or a command line that increment the variable part of the name of my files but some of them?

I have several files whose names aren't correct: $ ls devoirNote1_1_2.R devoirNote1_1_5.R devoirNote1_4_1.R devoirNote1_1_3.R devoirNote1_1.R devoirNote1.R devoirNote1_1_4.R devoirNote1_2_1.R ...
0
votes
1answer
2k views

Debian startup script doesn't start

I'm trying to make a specific script load on start on Debian. I have tried to put the script on /etc/rc.local but no success. Now I have made a service script that runs my specific script. The code of ...
0
votes
1answer
192 views

Loop through specific set of directories

The following code loops through ALL directories under current path to perform a count on compressed xml files: for i in *xml.gz; do echo "XML" "${PWD##*/}" "$i" $(gunzip -c $i | echo "scale=0; `...
0
votes
1answer
75 views

How to Execute Script Instead of Reading from File?

Is it possible to set up a file such that when it is referenced (opened for read), the contents of the file are not returned but instead the results of running a script or executable? I realise that ...
0
votes
1answer
297 views

I want to compare my awk result with a specific value by if condition

I have the result in below command. They are capacity of drives I want to compare to a threshold value. So I want to compare each line to a specific value. If greater then some condition follows. df -...
0
votes
3answers
195 views

awk or sed lines between same pattern including the first match

This is the text: * Tue This is the first line – info 1 – info 2 – info 3 * Wed This is not to be included The output of this text should be this: * Tue This is the first line – info 1 – info ...
0
votes
2answers
2k views

Command puts in expect doesn't show the message in the order it should

I have a some scripts to automate a process and I want the message about which step I am in it shows in the command window. A piece of code I have is: puts "** Creation of $VMNAME on $HOST begins... ...
0
votes
1answer
352 views

auditd script through crontab - bad date

I did create a central auditd server where i'am sending all audit logs form local servers. I would like reports accesses from a specific node. So I created a simple report sript where one line is ...
0
votes
2answers
36 views

Have this code here, need to copy files from a directory over to mine using scripts

So I have an array with some names. I need to find all the files in another folder with a certain pattern and copy those files over to my current folder. NAME=(JOHN) for i in ${NAMES[@]} do cp ~/...
0
votes
1answer
45 views

transfer data into columns

inputfile contains: dn: cn=wss_savvion cn: users cn: avvionvc owner: cn=SSC_admin owner: uid=GNG2938427 dn: cn=Web_Admin, EN=OC1Test cn: Administrators dn: cn=sample1, cn: TestPart1,Testpart2 Need ...
0
votes
2answers
2k 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/...
0
votes
0answers
5k views

“Invalid command name ” while executing, Expect error

I'm getting an error that says: invalid command name " while executing ""\r"" invoked from within "expect { -ex "--More--" {send -- " "; exp_continue} "*>" {send "exit \r";"\r"} }...
0
votes
0answers
69 views

A letter is missed in Russian words to be searched in VIM

When I run: $ vim -s <(printf '/конфедерация') VIM opens and shows '/конфедерция' in the left bottom corner without 'а'. Why? There is no problem with '/стол' for example. But if the word is a ...
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/...
0
votes
1answer
191 views

run loop for extracting part of a file name and run some commands

I'm new in bash scripting. I have some files in different directories and wanted to extract part of the filename or directory name and create a variable with that part and apply this variable on the ...
0
votes
0answers
68 views

What's wrong with this Nautilus script?

I'm trying to write a simple Nautilus script that lets me select a media file, right-click to get Nautilus script menu, and convert it into an mp3 using avconv name=$...
0
votes
1answer
56 views

Logging to a new file for a continues running script

I have a script providing login continuously( like 2-3 pages in a second). I was using below one liner. sh myscript.sh > /home/user/mylog I am running another script to zip this file when it ...
0
votes
0answers
247 views

Curl website hidden behind loading screen

Some websites (example) have a "loading" screen display before they show you their actual content. If I curl the site, I get this loading screen rather than the content which I want. How can a bash ...
0
votes
1answer
32 views

How to perform automatic backups at the same time every week?

so for a course I'm currently studying I have a test to do soon. (It's a low level course) We are using RHEL6 and we've been given a sample test to work through. There's one single question I can't ...
0
votes
0answers
266 views

Restart a running process if it outputs a particular string?

I want to loop a process in a bash script, it is a process which should run forever but which sometimes fails. When it fails, it outputs >>747;3R to its last line, but keeps running. I tried (...
0
votes
2answers
640 views

Tool to replace block in a file

Most configuration management software tools have a way to replace a block in a file. Example: SaltStack: blockreplace Ansible: blockinfile I want exactly this, but without the overhead of these ...