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
4answers
37 views

How do i write a script to run only if another script has run more recently?

I am attempting to write two scripts. But i run into problems when i try to prevent either one of them from running twice in a row. For example, i have script1 and script2. i want to be able to run ...
-3
votes
1answer
24 views

What is the correct expression to generate the correct result? [closed]

This script takes a CSV file and iterates over it to create a MD array. It then takes the third column and compares each variable to determine if it is greater than 64. I can get it to work if I use ...
1
vote
1answer
42 views

migrating to systemd a startup-shutdown script that works with tmpfs and bindmounts

BACKGROUND INFORMATION : I have an init script that allows me to mount a folder to tmpfs, while bind-mounting the folder on drive to another location, so I can sync the contents (on startup, ...
-1
votes
1answer
41 views

$* \ ||, eval and "\; mean?

Could you please explain the below code? What does $* \ ||, eval and "\; mean? Here below are the functions Initialization_variables error_message quit_error_chk Initialization_variables $* \ || ...
0
votes
1answer
33 views

Is it possible to sftp to multiple machines in single sftp command? [closed]

In my case, I want to sftp set of files to 3 machines using 1 sftp command in RHEL. Is it possible?
0
votes
1answer
102 views

Execute a command every minute forever using 'date'

I'm looking for a way (bash script or other) to make a command run every minute using date - I've been looking around for similar solutions but they all suggest either cron or watch but what I want to ...
2
votes
1answer
85 views

Bash script unable to move files

I'm trying to write a "janitor" script that will run as a cron job in one specific directory. It is supposed to create an archive folder with the date of creation in the name, and then find and move ...
0
votes
3answers
32 views

i want to print the line which starts with a paricular word and in the rest records print only 1st field

for eg: CREATE TABLE MWWDATA."VTCat02" ( "ID" NUMBER(10) DEFAULT NULL , "Cat" VARCHAR2(255) DEFAULT NULL , "Style_Code" VARCHAR2(255) DEFAULT NULL , "Vendor_Style_#" VARCHAR2(255) ...
1
vote
1answer
72 views

how to make scripts that shows Western Zodiac?

I want to make scripts that shows Western Zodiac which accepts as input a person's birthday on the command line and prints out the following: The day of the week on which the person was born Their ...
1
vote
0answers
102 views

Slow script execution

I have a strange problem... My script: #!/bin/bash SECONDS=0 lock_file=/tmp/$0.lock [ -e $lock_file ] && exit touch $lock_file echo "<<<db2_hadr_check>>>" instances=( ...
2
votes
1answer
220 views

use 'mail' to read email from command line

I know we can use mail command in terminal to start using the mail program in interactive mode. However, I want to read the email using mail command non-interactively. Is there a command like $ ...
1
vote
1answer
68 views

Script not working but command works outside of script

I have a very simple script that basically runs a command and then emails the report to a user: #!/bin/bash FROMDATE=`date -d "last week 13:00 " '+%Y-%m-%d'` TODATE=`date '+%Y-%m-%d'` ...
1
vote
1answer
152 views

Get the output from expect script in a variable

I have an expect script which provides the IP address: #!/bin/expect -f set nodename [lindex $argv 0] spawn virsh console $nodename expect "Escape character is" send "\n" expect "localhost login: " { ...
1
vote
1answer
149 views

Syntax error near unexpected token done when looping a multi-statement line

I have the following code as part of a larger file (assume ${tools_urls}, ${tempFolder} are global variables) download_tools() { for i in ${tools_urls}; do wget --no-check-certificate ...
0
votes
2answers
40 views

Sort list of currently logged in users and display one line containing the userid that sorts last?

Question is in the title. Sort list of currently logged in users and display one line containing the userid that sorts last? Feels like it should be simple, but I'm having trouble coming up with the ...
0
votes
2answers
14 views

Creating directories & subdirectories based on user input than display created directories?

Okay so I'm learning Linux in college. I'm really not that good, and want to improve a lot so bear with me. I wrote this code: Yes I know this code does not work, but maybe I can get my point across. ...
0
votes
1answer
55 views

How do I get a Debian server to output “screen -ls” on ssh login?

I read that I can add a line like this to /etc/ssh/sshd_config: ForceCommand /etc/ssh/loginscript.sh The "loginscript.sh" is executable and only does screen -ls until now. I suppose the problem is, ...
1
vote
1answer
66 views

passing sftp commands to sftp connection in a file

How can I pass a script to an sftp connection? e.g. I make the sftp connection thus: #sftpscript.sh serverIP="1.2.3.4" sftp $serverIP So far so good. Now I have a script the looks like this: ...
2
votes
2answers
485 views

using sudo -u <name> to run commands inside shell scripts

I'm extremely lazy, and prefer to write scripts to automate compiling software. To me, as these scripts can get quite long, it's easier to run them as root but have the individual software compile as ...
2
votes
2answers
69 views

Are there any sed scripts built in to mainstream Linux distros?

When I was studying bash, I found it very helpful to go and study the bash scripts already present on a clean install of Linux—/etc/profile, for instance, and anything in /etc/rc.d/init.d/. These are ...
1
vote
3answers
69 views

Downloading a few thousand files - how?

I want to download a few thousand files one by one. The average size of each one is 5-10Mb. Each has a name of "name_{i}", where "i" is a counter. What's the easiest and best way to do that? Note ...
0
votes
0answers
26 views

How to quote for Maildrop's xfilter?

I am trying to setup up a filter that resolves these "Re: AW: Re: Rif: Subject..." catastrophies. if( /^Subject: (Re: |AW: |Antwort: ){2,}/ || /^Subject: AW:/ || /^Subject: Antwort:/ ) { ...
7
votes
3answers
74 views

Remove certain characters from multiple files with whitepsaces

I'm trying to rename a bunch of music tracks in a directory, but I got this error: When moving multiple files, last argument must be a directory This is the script: for file in * ; do mv ...
2
votes
0answers
21 views

Automation: Autorearrange/reorganise Desktop Icons

I'm running Linux Mint 17+ on a laptop and I insert and remove external drives quite frequently. There are a varying number of other icons on my desktop, which I prefer asthetically pleasing, and they ...
5
votes
2answers
25 views

maintain prompt despite ouput flow

Short version Can I maintain an input symbol (> for instance) at the bottom of the terminal so that the user can input despite text flowing above? Long version I am making a multi-process ...
2
votes
3answers
200 views

bash - get pid for a script using the script filename

I have two scripts: running_script script_one I need to get the PID for the/any instances of running_script running under a username, and then pkill to stop the running_script and daughter ...
0
votes
2answers
25 views

Im trying to pull all the text past one point in a file and print it on the screen using bash

This is my input and output cat /home/$USER/Downloads/cudaHashcat-1.37/cudaHashcat.pot | grep : ...
4
votes
2answers
123 views

Read quoted array elements with spaces from file?

I'm passing data from STDIN into an array using read like so: prompt$ cat myfile a "bc" "d e" f prompt$ read -a arr < myfile But read doesn't appear to pay attention to the quoted strings and ...
3
votes
1answer
60 views

Is there a way to activate a particular tab of chrome via bash?

Suppose, for example, I have a chrome window active with gmail opened somewhere among its tabs (but not necessarily the active tab). Question: Is there a way to activate the gmail tab from the ...
4
votes
3answers
129 views

Use terminal-based documentation effectively (no web browser) [closed]

The problem I was trying to find shell scripting information without an Internet connection, i.e. via man page. Specifically, I was looking how to pass and use parameters. man bash does not contain ...
2
votes
3answers
38 views

need to move files with name into directories with corresponding names

I have files named patient_sample_L001_R1_001, patient_sample_L002_R1_001, patient_sample_L003_R1_001, patient_sample_L004_R1_001 another set named patient_sample_L001_R1_002, ...
2
votes
1answer
79 views

How can I get the correct end time of a nohup command?

#!/bin/sh set -x echo "Starting Time at "`sshpass -p xxx ssh -o StrictHostKeyChecking=no UN@IP 'date'` nohup ab -n 20000 -c 70 https://xxx.xxxxxx.com/xxx/xxxx/new.jsp & echo "Ending Time at ...
1
vote
2answers
66 views

Linux; run script when a specific host becomes reachable (logs in on AP)

I have a Debian Linux running on a RasPi. I'm looking for a way to run a script when another system becomes available on the network (aka logs in on my wifi AP). The AP is an AVM Fritzbox and as such ...
-3
votes
1answer
66 views

Please help assess what's wrong with my script

I'm attempting to create a script that loops through an entire directory of files in order to find the file with the most characters in that directory attached is my code sample. What am I doing ...
2
votes
1answer
73 views

Conditional Execution - Launching Persistent Sub-Processes and Coroutines

Conditional execution is used in Bash to control the flow of a script on the basis of the exit status of a subprocess. However, there are situations when a subprocess (application) is launched in the ...
2
votes
2answers
45 views

Help required to execute shell script

I need to write a shell script to see if the ADM Process is down we need to get an alert via email. I have done that using the script below. It is working fine if we have installed one ADM server on ...
0
votes
3answers
47 views

Need to write a “thirsty.sh” script: BASH [closed]

Okay I have all of the code and it's working. I am just having trouble with the while loop #asking the user if they are "thirsty". echo "Are you thirsty?" #creating thirsty variable read thirsty ...
-4
votes
1answer
36 views

Need to write “pickanumber2.sh” script [closed]

Name the script pickanumber2.sh. The script will get a random number 1 - 100. Ask the user to pick a number. If the user picked the correct number, tell the user. If not, tell the user if they were ...
2
votes
1answer
65 views

Unix ffmpeg Shell Script merge .aif and .mp4

I need a script that merges multiple files (.aif and .mp4) in the same folder with the same name to a new folder called [original_name]_new.mp4 Code: #!/usr/bin/env bash -e function combine(){ ...
1
vote
1answer
96 views

Skip first line (or more) in CSV file which is used to rename files

I have used the info from another question on Stack Exchange to allow me to rename files using the info in a csv file. This line allows me to rename all files from the names in column 1, to the names ...
2
votes
1answer
72 views

Cut command does not separate by tab in script

Note : I don't know how to insert tabulation in my text, I replaced it by [tab] I have a list file name value separated by a tabulation : host1[tab]ip1 host2[tab]ip2 host3[tab]ip3 host4[tab]ip4 ...
2
votes
3answers
56 views

Bash script to echo the first positional of each line into file with name of the second

I have a text file that is organized as follows: Group 1 asdsdsdsdf.html jeff xcvxcvxcvx.html bob vrgeiuvhif.html sue Group 2 iwdowijdoi.html mary pokpompojm.html doug ndkjfsjfbs.html lisa I ...
6
votes
6answers
659 views

bash: how do you return file extensions?

I want to write a script to return just the extension of the input file name. For example, textfile.txt should return txt. I'm new to Linux and bash, and I'm trying to learn how to write basic ...
1
vote
3answers
29 views

Bash script processing snmp text to only print desired ID

I am trying to create a bash script handling snmp responses the same way wether or not the OID is installed on the client. Clients can get the following responses: ...
1
vote
1answer
115 views

BASH AWK Script add days to fixed date

My task is to export data from a database with the UNLOAD TO statement in dbaccess and convert it into a file, that can be inserted into a similar database. Now the problem: The old database (let's ...
0
votes
1answer
23 views

Script add's md5sum to duplicate filenames but still get error notifications when executed

So by using some info from other threads on this site I have managed to get a script to copy files to another directory, then add the md5sum into the duplicate file names. However, I'm not fully ...
-6
votes
1answer
81 views
0
votes
1answer
36 views

Ignore parts of script under some circumstances?

My script looks like this strenggen ( ) { something; } strengen 1 strengen 2 strengen 3 strengen 4 strengen 5 etc.. Which adds a few files to the directory called strengen?string=1, ...
1
vote
3answers
199 views

How to split a “one-line text”, based on pattern? [closed]

I have a 1 line file ,contains non graphic characters and I want to split it based on a pattern. My pattern is \[0-9][0-9][0-9]; how can I do it? For example, I want to split this line: \001abd ...
2
votes
2answers
74 views

echo the directory with the information

The following script is working, I would like one more piece of information to the result. Besides the service rtvscand status, I also want to add where the file resides. Like: the symantec file ...