Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

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.

1
vote
1answer
15 views

korn shell - if a variable exists in an array stop processing without exiting

How would one evaluate priority of items in an array such that you only process the highest priority item that exists? Let me try to explain, if I had an array set -A array low medium none high ...
0
votes
2answers
37 views

Find and replace Pipe using awk command

I am trying to grep column 7th with pipe delimiter (|) data in that I have to removed pipe (|) from middle of text. Sample file: col1|col2|col3|col4|col5|col6|col7|col8|col9|col10 value1|value2|...
1
vote
2answers
3k views

script to add users to otrs

I'm 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/...
-1
votes
2answers
538 views

How do I take a prompt response and send it to a text file?

I want to ask the user what is their ORACLE_SID, ORACLE_HOME, and then send the output in a file. I want to create a param file that has ORACLE_HOME= ORACLE_SID= that is grabbed from what the user ...
0
votes
3answers
6k 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 ...
-1
votes
0answers
33 views

Script that checks a process's running status

I need to make a script that checks if a java jar is running on a particular port or not.If the jar is not running then the script should run it automatically. let's say I want to check if my jar xyz....
-4
votes
0answers
24 views

Linux script to move item from one folder to another

I want to write a script to read a file which contains the below information.The script needs to process each line. Folder A goes to Folder AX condition=name starts with RED Folder B goes to Folder ...
3
votes
1answer
353 views

Print proper log file from a terminal session

I am trying to log a terminal with the ssh user@ip | tee -a test.log command. But, when I push backspace it prints in the log like: pwe[J[J[Jexit (for example). Is there any specific option ...
0
votes
3answers
315 views

script; if status is this do that if not do something else

I need to write a script that checks on the status of something. If the status "Copying" then exit (or retry in 60 minutes if we want to get fancy.) If all there is nothing returned (based on my ...
0
votes
1answer
220 views

Bash Script - case esac - fails

Is the following script right??? It was doing OK until yesterday! I've written the following script to help a cron job running every minute and calling some other script which may cause a command to ...
-1
votes
2answers
468 views

Bash Script Problems

I'm working on a script... I don't know what is wrong with it... !#/bin/bash while="true" while ($while == "true") do clear echo "What game would you like to play?" echo "1. Tetris (bastet)" read ...
-2
votes
1answer
41 views

Scripting School Assignment renaming files without extension .old to have .old [on hold]

My goal is to change the file extension of files that do not have the .old extension to contain it after the script. Another goal is for me to do it with a for loop piped with grep -v to check match ...
0
votes
1answer
18 views

How to automate a series of keystrokes involving two GUI applications

I have two windowed applications that I need to send a series of keystrokes to. I need to Alt-Tab back and forth between the apps, and I'd like to be able to reduce the number of keystrokes from six ...
0
votes
1answer
938 views

Problem with inotify-wait as daemon

I have been running inotify-wait on my ftp server in byobu to monitor a folder, move data, and send email notifications for a few months without problems. Since I started this I have added 3 more ...
0
votes
0answers
1k views

How to write a script with Android Debug Bridge command in it

I am trying to write a script to automate some testing, and the fist step is connect to my device and update the /lib/modules/ directory with the recent version of a device driver on my host. That is ...
4
votes
3answers
2k views

Howto run interactive commands, as another user

I'm trying to write a bash script that context switches to another user (root, in this case) executes a set of commands to i. create a user (interactively prompting invoker for username) then ii. ...
1
vote
2answers
2k views

Nmap script execution to detect heartbleed is failing

Wanting to setup Nmap on my Ubuntu 14.04 LTS system to detect HeartBleed vulnerability. I followed the instructions here: http://cyberarms.wordpress.com/2014/04/20/detecting-openssl-heartbleed-with-...
6
votes
2answers
6k views

How do I sync files between two drives?

What command can check that a directory contains the same files as another directory, all the files are up to date and copy any updated files or new files to the first directory. It should not care ...
6
votes
8answers
7k views

How to display the IP address of the default Interface with Internet connection?

I need to create a script that outputs the internal IP address, that is configured as the default Interface.
2
votes
4answers
104 views

Variable in Date command

I want to use a variable inside date command . GNU date is not supportable in my system. I use Sunos and when I use date with -d option it is shwoing -d as bad substitution. #!/usr/bin/ksh ...
37
votes
7answers
95k 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?
1
vote
2answers
630 views

Extracting text blocks based on grep output

I'm currently working with a text file that contains the following text blocks: -------------------------------------- Beginning of block Text Random Text keywordA Text End of block ------------------...
0
votes
1answer
56 views

Script for backup each DB on server but omit system databases

I have read a lot of post around this topic but I didn't found the one to fit my needs. So, basically I want to make two backups: one at mid day (12 PM) and the other at midnight (12 AM) for each ...
0
votes
1answer
33 views

Find out if the connection to Wi-Fi was successful

I need to do some script, which find out if the connection to the Wi-Fi was successful or not. I have Wi-Fi configuration in /etc/wpa_supplicant.conf. I know how to add SSID and PSK to this file and ...
0
votes
4answers
39 views

Bash - changing fileconfig format

I would like to change: THIS: client 192.168.100.1 { secret = ThisIStheSECRET shortname = HOSTNAME } client 192.168.100.2 { secret = ThisIStheSECRET2 shortname = HOSTNAME2 } THAT: ...
-1
votes
6answers
3k views

How can I compare two files line by line?

I have two files A and B which are almost same with some lines different and with some lines jumbled. Since the two files are systemverilog files the lines also contain special characters like ; , = + ...
1
vote
2answers
7k views

How to use an optional argument?

I'm writing this script to work as a fast draft. It opens my text editor with date and time, so I can insert some draft text to save quickly. 1. At first I'd like to append the date and time at the ...
2
votes
2answers
1k views

Concatenate file contents AND names

I've been writing for many months. The files I create are dated files named like 2011-06-13.markdown with daily content. I've decided I want to have all the writing in one file instead but I'd like ...
1
vote
1answer
215 views
1
vote
2answers
35 views

How can I read a txt file line by line and sort them by the correct variables and write them to another file?

Here is an example of my txt file John NY 2019 APR Mark SC 2019 JAN Ava CA 2018 AUG Here is the example of the target txt file Name,Location,Year,Month John, NY,2019,APR Mark, SC,2019,JAN Ava, CA,...
2
votes
3answers
304 views

AWK & Bash: Checking that a User's Home is Owned by the User

I'm trying to cycle through /etc/passwd with a single-line command in order to find those users who have a home directory which is not owned by the user. The following has syntax errors in it, but ...
18
votes
7answers
21k views

History command inside bash script

History is a shell-built in command I couldn't able to use that within a BASH script. So, Is there a way attain this using BASH script ? Here we go my script for you: #!/bin/bash history | tail -100 ...
13
votes
3answers
11k views

Difference between commands in bash script and commands in terminal

Are there any differences between commands that you type into the terminal and commands you include in a script?
0
votes
1answer
24 views

Looping through all files, skipping some dynamically

rather new to unix. Trying to create a script to loop through all files and subdirectories given a directory and printing them. I would like to be able to skip certain directories dynamically though. ...
0
votes
1answer
31 views

auto enter password for `passwd <new user>` from script? [duplicate]

if the script was useradd ...............<new_user>; passwd <new_user>;. is there a way to put the new password in a script? I don't need to change or add an old password for an existing ...
25
votes
1answer
842 views

Finding files for which a command fails

I would like to recursively find all the files for which a script which accepts a file as an argument returns a non-zero value. Any idea how to do this using 'find' or a similar tool?
6
votes
3answers
6k views

Summing up an array inside of awk?

I have the following piece of code: sum1= sum2= declare -a a echo $temp | awk '{split($0,a,","); name=a[1] ; for(i=2;i<=4;i++) sum1+=a[i] ; for(i=5;i<=7;i++) sum2+=a[i] }' This code is not ...
2
votes
1answer
204 views

bash “for loop”

When I do, for ((i=0; i<"${ARRAY}"; i+=2)) do echo $i echo ${ARRAY[$i]} done echo $i works as I expected, also echo ${ARRAY[0]} works, but with $i as iterator i see only blank lines. How ...
6
votes
1answer
14k views

How to pass environment variables to a non-interactive shell (with example)?

In a sh script another sh script is started with su -l <user> -c /path/to/script.sh. As far as I understood script.sh will be run in a non-interactive shell. The official documentation tries to ...
2
votes
1answer
132 views

Sorting image files based on whether the content is picture or graphics: updating an older solution?

Someone wanted to sort files in a directory according to whether the files are pictures(camera) vs. design graphics. On Stackoverflow, there is an older solution/proof-of-concept involving the ...
1
vote
1answer
200 views

How to create a bash script that sees all files in a directory and tells me their size and date of creation?

I'm trying to write a bash script that will see all files in a directory, and then tell me each file's size and each of their dates of creation.
0
votes
1answer
61 views

<text_file.txt>:File or directory not found [closed]

I am working on a BASHScript to start wlan monitor mode without interefering with NetworkManager and I am having trouble with this function: serial_setup(){ local file_name=$1 while IFS =, read ...
1
vote
4answers
78 views

Git updates automatic notification

I'm trying to create a script that will email me if we have any updates for Git. I assume there are several easier/harder ways of doing this. Also, I have noticed that there are no highlighting ...
4
votes
5answers
8k views

Bash Script to Sort Files into Alphabetical Folders on ReadyNAS Duo v1

I have an old ReadyNAS Duo v1 (Sparc) running an unknown flavour of Linux. I have a folder structure with 1,000+ files I want to move into a folder structure based on the first letter of the file ...
0
votes
3answers
7k views

How to add users from data in a text file

I have a question about creating multiple users in linux, but I need a program to work on it. There is a new users txt file, the content is following: adams:5000:Adams, John Couch:/bin/bash atiyah:...
1
vote
3answers
372 views

Checking whether a date is within the next week

Trying to create a script for automatic SSL renewal with LetsEncrypt. Daily script begins with checking when SSL expiry is: response="$(openssl x509 -enddate -noout -in ~/letsencrypt/www.mydomain....
0
votes
1answer
14 views

Counting instances in a variable, then reformatting rows/columns within bash script

Within a Batch submission script I have a file generated called "nodefile.123" that looks like: bear-pg0208u33b bear-pg0208u33b bear-pg0208u33b bear-pg0210u19a bear-pg0210u19a ...
0
votes
0answers
17 views

Ubuntu 14.04 ,looking for script auto restart eth0

I got the problem on 14.04.3(default install iso, do not apply network update or upgeade to 14.04.6), the system sometimes network fail, can't ping other one and arp get the mac address show ,i need ...
-1
votes
0answers
16 views

Automating the addition of a new WordPress site on Nginx server

I want to build a script that allows me to add new WordPress sites to my nginx server. Currently, when I need to add a new site, I must manually do a few basic steps: Create an Nginx vhost config ...
0
votes
1answer
36 views

How do I increment an integer in an URL?

I want to scrape a forum by using an API and curl. API: https://api.hackertarget.com/pagelinks/?q=websitetotest.com Here is the initial link: https://bitcointalk.org/index.php?topic=840124.0 ...