A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.

learn more… | top users | synonyms (2)

0
votes
2answers
34 views

pausing a loop in AIX to wait for user input

I'm searching for a scripting mechanism that can realize the following idea. Loop over a list and stop/wait on "read x" until the next input from a user. I know the following script is not working! As ...
0
votes
4answers
957 views

Permission denied when run script via ssh

I wrote script which download via scp and install some packages. SSH keys are added to host and when I run [root@HostB ~]# ./myscript everything is ok and packages are downloaded via scp without ...
2
votes
1answer
23 views

Silhouette from an image

How can I create silhouette from an image in linux using the terminal? By creating silhouette I mean - how do I turn the RGB components values of an RGBA image to #000000, while preserving the alpha ...
-5
votes
1answer
56 views

Shell script to delete logs when the disk space reaches 90%

I need help to develop a shell script to delete the logs automatically once the disk space reaches 90%. I can add this shell script to crontab jobs.
1
vote
3answers
35 views

How to add the aggregated numbers in a file

I need to write a script which will add the values for the same string in different lines. For example when a file contains the following: abc,10 xyz,20, abc,30, ghd,40 xyz,10 script should check ...
3
votes
0answers
47 views

Check if a remote machine is in a cluster

How can I verify if a remote machine is a cluster machine? I just created the following ssh command to verify if the remote machine is a VRTS cluster or a Linux availability Red Hat cluster ...
8
votes
1answer
997 views

Can capabilities be used in scripts without setcap'ing the interpreter binary?

Right now I'm using cap_net_bind_service MY_USERNAME in /etc/security/capability.conf. Now I just need to set cap_net_bind_service+i on the interpreter of my favouite scripting language to be able to ...
0
votes
0answers
8 views

VBA loop through folders [migrated]

I´m trying to loop through folders on my brothers computer and what Im trying to do is to loop through the folders and the open the excel files contained in each sub folder and after copy that ...
1
vote
3answers
35 views

Script or command to list all top-level directories that contain sub-directories with modified files less than 30 days old

This is quite a unique one. I'm looking for a way to list all top-level directories in a folder that contain sub-directories with new or modified files less than 30 days old in them. We use a ...
3
votes
1answer
674 views

Execution time of pi calculation in shell scripts

I have to run a couple of command lines on a shell script on Ubuntu, one of those is a pi calculation. It works fine when i run it on terminal via the following cmd line: time echo ...
9
votes
5answers
8k views

How can I print only certain commands from a bash script as they are run?

I have a bash script with various if statements based on command line arguments I pass in when calling it. Having some kind of output as to what commands are being run is helpful to confirm the flow ...
0
votes
2answers
36 views

Script input filename or standard input

#!/bin/sh read vstup if [ -f "$vstup" ] then cat $vstup else if [ $vstup = "-"] then while [ $stadvstup != "q"] do read $stadvstup >> temp.txt ...
4
votes
2answers
44 views

Best way to delete select email messages from mbox file using script

I have an arbitrary email messages file in mbox format. I would like to periodically (end of the week), and automatically (via cron) purge messages from my "alerts" mbox file (new folder) just from ...
0
votes
1answer
44 views

Bash script fail to detect disk

I got a script that is supposed to reformat and mount /dev/disk/by-label/backup_disk into /mnt/backup_disk. Like this: /sbin/mkfs.ext4 -q -L backup_disk /dev/disk/by-label/backup_disk mount -t ext4 ...
1
vote
2answers
25 views

Script - numberlines

I would like to make a script, which allows user to input some text and it will output the same text with number of lines. Example: Input: Hi Jack, how are you? Output: 0001: Hi Jack, 0002: how ...
1
vote
1answer
72 views

Safe way to install .sh script in /usr/local/bin?

I want to include correctly the following script in Ubuntu 16.04. Code #!/bin/sh # http://tex.stackexchange.com/a/20886/13173 # $Id: pdf2eps,v 0.01 2005/10/28 00:55:46 Herbert Voss Exp $ # Convert ...
0
votes
1answer
40 views

Script too slow ? Any particular reason?

I have a script which does hexdump along with pipeline commands and finally I am redirecting it to a file. Now I am logging data from the serial port of my Raspberry Pi. I also call a python ...
0
votes
2answers
520 views

Unix Shell script to delete all traces of itself after execution through crontab

My Question has 2 parts. Help with both parts is greatly appreciated. GIVEN INFO: - Lets assume there are 2 Folders, Folder A and Folder B. - Folder A contains many files. - Folder B contains the ...
1
vote
0answers
25 views

Access to bash arrays in gnuplot [duplicate]

In a bash script I have several arrays which I need to access in a gnuplot code: #!/bin/bash ... # fill array a[*] and b[*] ... gnuplot <<EOF do for [j=0:10] { # access ${a[j]} and ${b[j]} } ...
-3
votes
1answer
62 views

Need help in a shell script

I need help with the below shell script. I have three environments: test, dev and prod. When the user enters test it should ftp to test host and ftp the file. Same in case of dev and prod. I have just ...
1
vote
0answers
12 views

Linux Mint Corners Musical Sequence Associative Array

I am writing a script which uses hot corners to play specific musical notes when hovering in corners, and depending on the musical sequence to execute a specific command. The script is called with ...
0
votes
2answers
66 views

Using regular expression to extract content of file [closed]

I have a link and I would like to return only content between www. and .com e.g www.blablabla.com would return only blablabla How could I do that? When I use grep '\.[a-zA-Z0-9\.-]*\.' it gives me ...
1
vote
1answer
122 views

Evaluation of find ( -exec )

I'm searching for all files that contain one of a set of strings. If they do, I change their access rights. find . -type f -exec grep -q '#!/bin/bash\|#!/usr/bin/grep\|#!/usr/bin/awk' {} \; -exec ...
6
votes
1answer
242 views

How to use less in a script without getting ESC escape characters?

When I use less at the command line the output is like but when I use less from within a bash script I get: How can I use less in a bash script and not get all the escape characters and have it ...
0
votes
1answer
21 views

Filtering time using last command on Solaris

I'm connected on server using Solaris and need to filter only people who were connected there until 28.4 00:00. How do I do that on Solaris? In bash I have -t option which does what I want.
1
vote
2answers
993 views

script to add users to otrs

Im looking for a fast way to import customer users into otrs (ticket system) I have an export from Active Directory with: firstname lastname password email username There is a script in the otrs/bin ...
5
votes
7answers
9k views

Sort the files in the directory recursively based on last modified date

Sort the files in the directory recursively based on last modified date I have modified a lot of files in my directory want to know what are those files by sorting them by the last modified date ...
1
vote
1answer
35 views

Trying to copy/paste long script with multiple EOFs, Terminal starts running half-way through

Was trying to create a text block that I could just copy and paste into a Terminal window to accomplish something (in this case, create a systemd script to do maintenance on MySQL dbs, create a timer ...
1
vote
4answers
34 views

Compare characters

I have two lines, which are saved in two variables. But it doesn't really matter, where they are saved. My question is, how do I compare each character from both lines? For examples Hello Hlleo ...
-1
votes
2answers
47 views

Where can I practice my Python and Bash scripting? [closed]

I wanted to practice my bash scripting skills and python skills and wanted a good book or a site where I can practice and get excellent skills please. Any recommendations please.
1
vote
1answer
46 views

Bash print current line, line's output, and linebreak to file

I've got a txt of a bunch of domains I need to run dig +short mx on. I've got a script set to run the command, print it to a results.txt with: ./dig_domain_mx.sh > results.txt Downside is, I ...
1
vote
0answers
21 views

Script - printing specific lines [closed]

I would like to print every line from text file with for loop, but somehow it doesn't work. It writes error: head: invalid option -- 's' I haven't used 's', so why it output with this error? ...
2
votes
1answer
744 views

Error passing variable from bash to php

I have the following files: vars.txt C=1234567890 Ascript.php #!/usr/bin/php <?php var $C="$argv[1]"; echo "\n $C \n"; $con = mysql_connect('localhost','root','123') or die ("No connected"); ...
1
vote
1answer
879 views

Error QProcess: Destroyed while process is still running

Edit: I discovered that the problem is not related with the script cited below, but I'll leave it there just for history. Well, this error appears when I close texstudio with the viewer open (xdvi or ...
4
votes
4answers
4k views

How can I extract/parse a complete URL from a semi random string?

I'd like to have bash parse/extract a full URL (and only the url) from a random short string. Examples: bob, the address is http://www.google.com or https://foo.com/category/example.html is up ...
0
votes
3answers
23 views

Getting the first 5 characters of unix filenames

I have Unix filenames like the following and I need to extract the first 5 characters of the filenames. I know you can use cut to extract the field content but I’m looking for getting the first 5 ...
-1
votes
1answer
23 views

adding date to beginning of file name using script

I have multiple files that need to be renamed with a date added to the beginning of the file name that I am trying to script. I'm using the cp command because I need to keep the original file I need ...
0
votes
2answers
49 views

List Most Recent File per Sub-Folder

I have a File structure of : FOLDER/SUB_FOLDER/Text_File I have over 1k+ FOLDER and each FOLDER has at least 2 different SUB_FOLDER with each SUB_FOLDER their own Text_File. I'm trying to ...
-2
votes
2answers
65 views

Keep CPU busy at certain percent (to prevent CPU buzzing frequency noises) [closed]

On Dell Inspiron 7559 there is electric buzzing from beneath the keyboard that changes frequency when I touch the touchpad. However, if the CPU is busy I hear no buzzing as the frequency gets out of ...
0
votes
0answers
56 views

Executing remote code with arguments

Why this: ssh -i ~/.ssh/master.pem ec2-user@xx.xx.xx.xx 'bash -s' < `dirname $0`/elements/"$element" returns hostname.sh test-5000: No such file or directory when $element is not a just a single ...
6
votes
3answers
78 views

sed/awk subscript numbers in chemical formulas using markup tags

I have hundreds of text files that include chemical formulas together with narrative including numerical values. The formulas are always preceded by white spaces but can be followed by white spaces, ...
14
votes
5answers
27k 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?
-2
votes
1answer
67 views

quick and easy way to comment out multi lined print statements

Is there a quick and easy way to comment out multi lined print statements? something like this? printf("3387 strings_line_tokens[lower_bound_of_big_boy_counter] %s \n", ...
15
votes
7answers
7k views

Using notify-send with cron

I am using Arch Linux with KDE/Awesome WM. I am trying to get notify-send to work with cron. I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without ...
0
votes
1answer
36 views

How can I avoid being prompted for a password in this script? [duplicate]

I’m using Amazon Linux. If I login as my “otheruser” user, and create a script, test.sh, with this text sleep 5 ; sudo reboot now I can login and run the script like so … [davea@mydevbox ~]$ sudo ...
0
votes
1answer
84 views

Parse xml returned from curl within a bash script

I've been digging through stackexchange for the past few days and I've found bits and pieces of what I'm trying to accomplish, but I'm unsure how to put it all together... I'm trying to create a ...
4
votes
5answers
203 views

How shrink test -eq expression with more than one var value in /bin/sh

#!/bin/sh if [ $num -eq 9 -o $num -eq 75 -o $num -eq 200 ]; then echo "do this" elif [ $num -eq 40 -o $num -eq 53 -o $num -eq 63]; then echo "do something for this" else echo "for other do ...
0
votes
1answer
29 views

Source ~/.bashrc when using the shell recorder `script`

I am using the first answer from How to automatically record all your terminal sessions with script utility to record my terminal sessions, however, I can not figure out how to get my bashrc to be ...
1
vote
3answers
2k views

Split XML file into multiple files

I have an xml file that have different nodes, I want to split files like this: <unix> <mm> </unix> <osx> <nn> </osx> When I run the script I want it to make ...
3
votes
1answer
48 views

How to revoke access for a particular user?

How can I revoke all access (r,w,x) for a particular user to a file or directory tree (while still giving read permission to others)? Does setfacl with mask allow this ?