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 (1)

1
vote
1answer
524 views

Create a iptables rule if the rule does not all ready exist

Hi I've created a script to setup Nagios on my remote servers. My Script checks iptables to see if a firewall rule all ready exists and then is supposed to add the rule if it's not all ready there. ...
2
votes
3answers
246 views

Remove spaces and headers from a dumped database table

I have dumped the database table data into a flat file and below is how the data looks like : (Kindly copy from below ;metier_code ; ;-------------------------; (0 rows affected) ...
1
vote
1answer
225 views

What does “if [ -e $name ]” mean? Where $name is a path to a directory

In the if [ -e $name ], what condition check is -e? $name is a variable of a path to a directory.
1
vote
1answer
35 views

Limiting readers on a pipe

I want to use a pipe to pass some security credential information from "process1" to another script. I only want authorized reader processes to be permitted to read the pipe. I am thinking I will ...
3
votes
3answers
115 views

How can I automatically log in to a list of servers to prevent account lockout?

I have started a new contract, and need to have an active account on almost 200 servers. Security has accounts lock after 30 days of inactivity, as well as if you do not log in within 1 hour of ...
2
votes
1answer
30 views

Script. How to sort and move catalogs

I have some trouble writing a script. I don't know how to sort and move catalogs. #!/bin/bash while read -r line; do mkdir "sd/$line" done < 1a.txt After reading information from 1a.txt ...
4
votes
3answers
130 views

Generating diagrams (in PNG or JPG) from console?

From these data I can create a diagram in OpenOffice: $ cat time.log 2014-04-29 08:15:34 1.00 2014-04-29 08:15:36 1.00 2014-04-29 08:15:42 1.50 2014-04-29 08:15:47 2.00 2014-04-29 08:15:55 2.00 ...
1
vote
1answer
205 views

bash scripts - remove duplicate rows with smaller value

Here is an example file: 1 5 20 40 60 2 1 20 20 20 2 2 30 30 30 4 5 40 40 40 7 2 50 30 30 7 1 20 20 20 I would like to remove duplicate rows (with the same value in the first column) with a bigger ...
2
votes
2answers
67 views

How to format textutil -excludedelements

I use Geektool on the Mac to display various information on my desktop. One feature of Geektoool is the ability to use shell mode to launch custom scripts or commands. I am not versed in any type of ...
0
votes
2answers
469 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 if anyone can help.             ...
1
vote
1answer
48 views

How to add a dot to particular lines in LaTeX-document?

I have a LaTeX-document where I have lines of the form \section*{3.1} \addcontentsline{toc}{section}{3.1} or in general \section*{x.y} \addcontentsline{toc}{section}{x.y} for x between 1 and 31 ...
1
vote
1answer
126 views

Script or command to replace default parameters in /etc/user on AIX

I wanted to change the parameters settings in /etc/security/user file in AIX OS using a script. This is the sample user file. default: admin = false login = true su = ...
0
votes
2answers
60 views

Different forms of executing a shell script

There are a few similar questions around that I've already seen, but I've come up with something different. I'm reading this http://www.tldp.org/LDP/abs/html/invoking.html and I got confused when I ...
2
votes
1answer
157 views

How to make a bash script wait till a pendrive is mounted?

I have a bash script which has a line cd /run/media/Username/121C-E137/ this script is triggered as soon as the pen-drive is recognized by the CPU but this line should be executed only after the ...
-2
votes
1answer
87 views

Comment multiple line using SED

Seeking help how can i comment multiple lines using SED, i like to comment ftp, telnet, shell, time, ntalk, daytime in inetd.conf file. Thanks in advance
-2
votes
1answer
24 views

I want a script to do following simple task?

My input is : a a l a c g b c ... and so on rando alphabets. A command or a awk statement which will give me: a-1 1-2 l-1 a-3 c-1 g-1 b-1 c-2 basically counter for all alphabets and ...
5
votes
1answer
444 views

Save password in bash script for multiple queries

I would like to know if there is a safe way to only be queried for a password once in a custom bash script, and then save it somehow to be used for later needs. At the end of the script it should be ...
2
votes
1answer
55 views

I'm trying to count and print song file names using awk as following

RANK NAME BAND YEAR GENERE DOMESTIC/INTERNATIONAL 206:Reach Out, I'll Be There:The Four Tops:1978:Pop:3/2 207:Bye Bye Love:The Everly Brothers:1950:Classic:3/2 ...
2
votes
2answers
45 views

Capture transcript of program with redirected input and output

A typical interaction for a program I've written might look like this: Enter command: a_command Completed a command Enter command: another_command Completed another command I typically run my ...
2
votes
1answer
56 views

Switching between 2 windows on Linux

Hi I need to switch focus between two windows periodically and automatically (with software or w/e). Can this be achieved on linux?
1
vote
1answer
42 views

linux if else fails for some IP's

i am using the following code with if then to mount. It works for some IP's, it does not work for some IP's especially for FAILURE statement. Here is the code is_mounted() { mount | grep -qohw ...
4
votes
2answers
4k views

Shell script wait for background command

I am writing a script, but there is something I need that I can't find a way to do it... I need to make a command in background "command1 &" and then somewhere in the script I need to wait for it ...
4
votes
2answers
189 views

Faster way to rename duplicate files (identified by fdupes) in another directory?

I have a directory full of pdf files of journal articles, most of which are named by their bibtex key. Some time ago I made a backup on an external hard drive, but I haven't kept it up to date and ...
0
votes
2answers
55 views

Is it possible to cache external binary in a shell script?

My question, might sounds a bit strange, but this morning I read this question: Why is “echo” so much faster than “touch”? I perfectly understand the concept of built-in function, but I wonder if you ...
3
votes
2answers
194 views

Does cron know that the instance to be scheduled is already running?

I was wondering if we add a job in the crontab e.g. to run every 5 mins and the job does not actually manage to finish in 5 mins, does the cron daemon know that the previous instance is already ...
3
votes
0answers
35 views

Control browser from command line [duplicate]

I have an old router that I have set up as an AP on my home network. For some reason it loses connectivity every few days and needs a reboot. I would like to set up a script to run once every night ...
-2
votes
2answers
56 views

How to delete a directory from terminal?

I'm trying to delete a directory after a series of events take place. That being said, I need to be able to place this in a file to execute once said events take place.
0
votes
1answer
52 views

Script: Running a second process when the firts ended

I am trying to make a script that consist in a two parts. the first one is to run a initial state and the second one is to equilibrating the system. The problem is that the second is dependent of the ...
0
votes
2answers
150 views

Scripting Language Evolution [closed]

I have an assignment due Monday and I need some help because I have no knowledge on the subject and can't even understand what to search exactly. I am not waiting for an essay or something just some ...
2
votes
7answers
1k 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 ...
5
votes
3answers
312 views

How to rescale several images to same size

I have several image files in a directory. These images are similar size and have same background color. How can I make all images same size by adding background like this attached image?
1
vote
3answers
70 views

awk want to total by hour and variable

I am able to run this and it works fine - note: field $1 is a time/date stamped field.. gawk -F ":" "{ print $1 }" /cygdrive/c/counting/ourlog | sort | uniq -c | sort -r 57339 2014-03-21 09 54290 ...
4
votes
3answers
2k views

Execute a command on user logon

In Linux desktop system, I want to execute a command when the user logs in. After reading some other posts, I tried to insert the command in ~/.bashrc but unsuccessfully. Moreover, the system uses a ...
1
vote
1answer
185 views

Cron task in graphic interface

I need to open one (or more) browser tab periodically and I decided to use cron. The command in the shell (bash) that correctly executes this task is chromium-browser http://mysite.com. If I type it, ...
-1
votes
2answers
126 views

Rename filename.JPG to filename .jpg recursively [duplicate]

Rename filename.JPG to filename .jpg recursively I want all the files with .JPG extension to be changed as .jpg
1
vote
1answer
112 views

how to check if mysql table is used or an application accesses the table in shell script?

A shell script is doing dump for a mysql table, but before dumping the table I want to check if this table is used by any other application. If so, I want to wait and enter in a loop until the ...
2
votes
1answer
50 views

Beginner question about 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 ...
3
votes
1answer
18k views

Convenient way to check if system is using systemd or sysvinit in BASH? [duplicate]

I am defining common bash files which I want to use across different distributions. I need a way to check if system is using systemd or sysvinit (/etc/init.d/). I need this so I run appropriate ...
4
votes
4answers
641 views

Bash Scripting : Printing column data in the same row

I have written a bash script to calculate the size of a PostgreSQL database and print the output along with the date when the script was executed in a text file. The script code is as follows: ...
3
votes
2answers
72 views

Bash script : help file inside the script or in a different file?

I'm writing a script that has the vocation to be a fully featured program at the end. As far as I know, BASH is enough for his purpose (manage PPA's, kinda like Y-PPA). I would like to know how to ...
1
vote
1answer
57 views

Wait until no incoming network connection for N minutes, then execute a command

I want to put my Debian Wheezy home server to sleep, if it wasn't accessed through the network for a certain amount of time. I thought of a bash script that uses netstat to count the number of ...
1
vote
3answers
316 views

Delete files with same name at the end of the file

Delete files with same name at the end of the file i have a lot of files in my folder and sub directories like ajax_hostel_room_master.php.php class_hostel_registration.php.php ...
1
vote
1answer
867 views

Can Start Service With init.d script, however doing service <SERVICE_NAME> start does not work

I am running CentOS 6 and I am trying to get my Oracle database to run at startup. I have been following these steps: ...
0
votes
1answer
60 views

feeding the password without any terminal window (stdout)

I have a command like this: echo "12345" | sudo abcde where 12345 is supposed to be the root password and abcde a program or a command. I have a shortcut which runs this command. I have tested the ...
6
votes
1answer
209 views

When is it important to write portable scripts?

Most code I write is in PHP. I have recently started learning shell scripting. Most of the resources and tutorials that I've come across are specific to Bash. Some warn about bashisms and some don't. ...
3
votes
5answers
268 views

How can I force a script to use more resources?

I'm running a very time-consuming script which takes many hours to end. Watching top I see that it's only taking 5% of the CPU at best, usually around 3%. Is there any way to force the script to use ...
1
vote
0answers
53 views

Logging into multiple SSH servers as root and create an user with same power as root does [closed]

I need a script from which I can log into multiple servers as root (but not all root passwords are same;there are 3-4 different root passwords) and make a superuser (user with same access as root) but ...
9
votes
3answers
222 views

A shell-like environment for binary processing

This question came to me a couple of times before, now in response to the question Loop through binary data chunks from stdin in Bash Answers given in ...
0
votes
2answers
40 views

Help With Simple Script - Absolute, Relative Paths

I'm trying to execute a mono application, without requiring the user to type in 'mono filename'. It's just one line of code: mono ./Bin/jobshop.exe $1 $2 $3 $4 $5 $6 $7 $8 $9 It works great, so ...
2
votes
4answers
108 views

Wrapper command that runs program in temporary directory and deletes it after execution [duplicate]

I want to write a command that: takes another command as its arguments does a 'cd' to a temporary folder executes the command passed in the arguments removes the temporary folder afterwards ...