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)

0
votes
2answers
27 views

Write log for a false statement of an if condition which returns exit 2

I have a script running every 5 mins with two exits in a condition clause. #!/bin/bash date=$(date +%Y) if [ $date -eq '2014' ] then echo "Current year is $date" exit 0 else echo "Current ...
1
vote
5answers
46 views

grep for text that may or may not be present

Lets say I have a file batman; robin; superman; password = ""; wonderwoman green lantern if I want to check if there is a password present, i.e there is something entered in the "" . here is an ...
1
vote
1answer
29 views

Assign diff -y column names

I have two files and a shell script. File 1: Batman Superman John Snow Jack Sparrow Rob Stark File 2: Batman Ironman Superman Spiderman John Snow Arya Stark Jack Sparrow Rob Stark The hound ...
2
votes
3answers
250 views

Comparing text files using Bash and AWK

I have two text files, and I want to compare their corresponding values according to their rows and columns. By comparing, I mean to check if the values are equal and echo if the values are the same ...
1
vote
2answers
38 views

What does this regular expression do?

I have been provided a %post script inside a spec file to edit a config file (called foo). I have ben tasked with writing another, almost identical script to edit a file called 'bar'. While my ...
-1
votes
1answer
34 views

How can I search for a user account in various sudo related config files?

I'm a scripting newbie...and I would like to search multiple servers for user ss7459 in the following files /etc/sudoers, /etc/sudoers.d/itse, /etc/sudoers.d/dbas and /etc/group. NOTE: The numbers ...
0
votes
1answer
58 views

How do I log out/disconnect from SSH after starting a process with output to keep it running? [duplicate]

I ran a script from the command line today (php, not sure that matters) which has output I wanted to watch but I had to go home before it finished and I couldn't figure out how to exit without killing ...
2
votes
1answer
59 views

SSH Command behaves differently in Expect Script

I'm using this command on Server1 ~# ssh root@Server2 /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys to append the contents of Server2's id_rsa.pub to the authorized_keys of Server1. It ...
1
vote
6answers
81 views

Is there a way to find out the number of lines from a command output?

I am trying to compare command outputs between two servers. I want to find out the number of lines from the output of commands such as ls -l. Is there a way to do so? So far I have not found anything. ...
1
vote
1answer
41 views

gphoto2 hook scripts - a guide?

I posted this on raspberrypi.stackexchange but was directed here. I'm new to Linux / Unix, and I'm trying to get a tether / display script going with gphoto2. gphoto2 --capture-tethered ...
3
votes
3answers
145 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. ...
3
votes
5answers
229 views

How do I extract the content of quoted strings from the output of a command?

I have output from VBoxManage list vms which looks like this: "arch" {de1a1db2-86c5-43e7-a8de-a0031835f7a7} "arch2" {92d8513c-f13e-41b5-97e2-2a6b17d47b67} I need to grab the names arch and ...
1
vote
2answers
48 views

How to convert text or character to hex in korn shell

Does the unix korn shell provide a function to convert text or character to hex eg. hex 31 32 37 33 34 35 35 36 36 37 value of characters 1273455667 Here i have written the code to display but i don't ...
0
votes
0answers
25 views

xdotool random/more natural delay?

For automated testing of some applications, I would like to emulate the users behaviour. I know I can user the xdotool type --delay option, but I would like a more natural delay. The easiest thing ...
3
votes
3answers
58 views

Print a string including single quotes and other special characters

How can I write this with an AIX script correctly? My requirement is to write this command in test.txt: clock=$(prtconf -s | awk '{print $4,$5}') I tried this command: print 'clock=$(prtconf -s | ...
3
votes
2answers
67 views

Error when calling mv with wildcards

#! /bin/bash error_text=$(tail -n +1 /path/dir/folder/exc/a/update/Abd/ER/* | \ grep 'Warning\|Loaded\|Event') echo $error_text nc 10.10.99.45 25 << EOF ehlo mail.abc.pvt mail from: ...
3
votes
2answers
78 views

Checking the status of custom services with a script

I have a handful of shell scripts that start WebLogic managed servers. I need to design a master script that does the following: Executes the shell script for a component\managed server Checks to ...
0
votes
1answer
101 views

SQLPLUS withing shell script loops

Hello I am trying to run a loop and get the details of a project. I have these projects in my work space. How do I loop over the SQL code? #!/bin/bash workspace=$(sudo locate -r '/workspace$') ...
0
votes
0answers
26 views

shell script for executing mux verilog code

I have a verilog file mux.v and testbench muxTB.v. used ifdef caeses for behavioural model ifdef struct for structural model I have executed these files using the commands iverilog mux.v muxTB.v -D ...
0
votes
1answer
53 views

Is there a way of copying only directories and not files in bash? [closed]

I want to copy only directories from a folder on a remote server to my server. Is that possible? Here is the code I have so far but it copies files and folders: scp -rq ...
0
votes
2answers
97 views

Linux - Delete last two files automatically

In Linux, one folder is created every morning and 5 files are created in that folder. At the end of the day (Midnight), the last two files in that folder have to be deleted. How can I accomplish ...
3
votes
5answers
119 views

Look if a folder has some files of certain extention

Lets say I have a file structure: $ cd /home/Desktop $ ls -d */ Abc/ Qwe/ Zxc/ Rty/ $ Now I want to iterate through every directory and look if they have any .pdf files. Could some one please ...
0
votes
1answer
93 views

How do you keep the password hidden when invoked during the su command?

This is the first time it has happened to me where I am using the su command and it actually displays the password on the terminal and doesn't stay hidden. Here is my code snippet: sshpass -p ...
0
votes
1answer
63 views

script to compare two string “foo” and “bar”

I'm going to create a script that should print "foo" or "bar" when a user's input is "foo" then print "bar" or when the user's input is "bar" then print "foo", otherwise show "invalid string". Here's ...
0
votes
0answers
27 views

convert many eps files in a single pdf or ps file using shell scriptI

I have SSt12.OLR.1.eps, SSt12.OLR.2.eps SSt12.OLR.3.eps SSt12.OLR.4.eps ......and covert these eps files into single pdf or post script file. please suggest a shell script.
1
vote
1answer
129 views

Shell script and crontab to capture file size, name and date in a CSV file and then send via email?

I have a number of zip files in a certain folder. I want to capture file name and the size of the files in a CSV format in day wise and put it in crontab so I can report on a daily basis, and then ...
0
votes
2answers
66 views

Simple Script to setenv tcsh or export bash

I am having problems with simple scripting, my Box is CentOS so bash is the default shell, now I wanted to send a line via setenv (tcsh) and would like to make a script that will ask me to input a ...
1
vote
2answers
103 views

Changing user to root when connected to a linux server and copying files

My script is coded in a way that doesn't allow you to connect to a server directly by root. This code basically copies files a server to my computer and it works but I don't have access to many files ...
2
votes
3answers
97 views

Need help to combine 3 split lines of bash script into one single line

The following is what I found after googling: dpkg --list 'linux-image-*' \ | perl -ane 'BEGIN { $r = `uname -r` or die; chomp $r } print $F[1], "\n" if $F[0] eq "ii" && $F[1] !~ ...
0
votes
1answer
52 views

How to execute grep in tcl for getting XYZ-123 type pattern

can I execute this grep command in TCL? grep '[A-Z][A-Z][A-Z]\-[0-9][0-9][0-9]' file1 > file2
1
vote
3answers
236 views

How to capture error message from executed command?

I was tasked to create an automated server hardening script and one thing that they need is a report of all the output of each command executed. I want to store the error message inside a string and ...
1
vote
3answers
80 views

Merging multiple tab-delimited tables based on common columns

I am new to the field and I want to compare and merge 500 hundred tab-delimited files, each with two columns ("Position" and "Poly"). Examples of file1, and file2 (and other files) and the final ...
3
votes
3answers
276 views

Case-insensitive substring search in a shell script [closed]

I'm trying to create a script which runs a command and compares the output of that command to a certain string to see if it contains that substring, ignoring the case of the string needed to be ...
2
votes
3answers
106 views

grep on a Java Method

Lets say I have a java class called DirectAction some of the methods in the class have the word "action" or "Action" What is the grep command to get the names of all the methods who have "Action" or ...
3
votes
3answers
180 views

Shell script to replace string in multiple files within selected directories

I created the script below which takes the path of a single directory and replaces search string in all the files within that directory. I would like to enhance this script in such a way that it can ...
1
vote
1answer
47 views

Can't spawn backgrounded process

My team's using Pallet (think Puppet in Clojure) to automate server provisioning, but running into a fairly fundamental problem: Pallet can execute arbitrary scripts directly on target VMs, but if one ...
0
votes
2answers
58 views

shell or python script to transpose rows to columns [duplicate]

I have a big file with numbers like: 1 2 3 4 5 6 7 8 9 9 9 9 I want to tranpose it into 1 5 9 2 6 9 3 7 9 4 8 9 I have search on google for solutions, but those solutions simply don't ...
0
votes
1answer
73 views

Linux script for printing name [closed]

I have to Prompt the user to enter his/her name and Print all combinations of three letters from the name. How to write script for this?
0
votes
0answers
29 views

Is it possible to auto translate words via scripting language?

Some words in String.log as following: English Home Wait Come Back And I want to translate words of String.log into French,like this: Anglais maison attendez venir arrière As we all ...
0
votes
1answer
57 views

Python file issue from root path

I have a script that is well-tested and known to be working. I am running into an issue with it where when I try to run it from /root/backup/script.py or ~/backup/script.py I get a file not found ...
2
votes
2answers
65 views

How do I run a command on each input given a list of input

I have a bunch of folders, and I want to cd into each folder and run a command. I feel like it should be something like this: (The following is a contrived and simplified example of what I want to ...
2
votes
0answers
52 views

How to print the first three lines and last two lines of a file using perl?

Through the command line I draw one or several of the patterns found text.xml file: perl -ln0e 'while(/<PMResult.*?<\/PMResult>/gs) { $x=$&;print $x if $x=~/BCCEL-[1-3]/}' text.xml I ...
0
votes
2answers
319 views

Run a script at startup

I am using Ubuntu 14.04. I wrote a small script named trial. The contents of the script are as follows: #!/bin/sh SHELL=/bin/sh PATH=/bin:/sbin:/usr/bin:/usr/sbin sh -c firefox I copied the ...
4
votes
0answers
35 views

How to detect a desktop application hanging

I want to write a script that will detect whether a particular desktop application is responding and kill it. Is this possible? I know I've seen the GNOME desktop put up a "Application is not ...
1
vote
1answer
38 views

Delete a matching line in a file doesn't work

So, I have this piece of a code: while read line do if [ $line = $maddr ] ; then sed -i '/${maddr}/d' mailinglist found=true ...
1
vote
4answers
181 views

renaming multiple files increment order

I have the following files SSt12.precip.374.sub.climatology.ctl SSt12.precip.2874.sub.climatology.ctl SSt12.precip.3764.sub.climatology.ctl SSt12.precip.6774.sub.climatology.ctl I want to rename ...
4
votes
1answer
39 views

Memory consumption of a script

Is there way to check the memory (physical & virtual) consumption of a script, of course in the moment of its execution. Calculating the used memory minus the used memory before and after the ...
0
votes
2answers
74 views

Awk printf number in width and round it up

I need to printf a number out, but with given width and rounded (with awk!) %10s I have this and somehow I need to connect the %d but everything I do, ends up with too much parametres for awk ...
7
votes
2answers
367 views

Check bash/shell script dependencies

Is there a method/command to check for the dependencies of a bash script? In other words, a response to this question : Which libraries should a user install to run the script? I can do this ...
1
vote
3answers
291 views

Bash script for automatic tar backup of chosen files and directories

Within a given directory in linux environment, I need to pick all files modified after a certain date (let's say 7 days) as well as all directories (only in root directory, hence non recursively) ...