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
49 views

failed to stuff “ctrl-a H” to a screen session

I need to toggle logging from outside of a detached screen session. Interactively you do this by pressing ctrl-a H. Their octal codes are \001 and \110. (source) What I tried: $ screen -S test ...
0
votes
2answers
172 views

Configure localtime. dpkg-reconfigure tzdata

I'm using this to configure localtime: dpkg-reconfigure tzdata It is ncurses interface. I'm looking for the way to programming this. Is there true way without user ncurses interface? How to ...
3
votes
2answers
81 views

The reverse of `tree` - reconstruct file and directory structure from text file contents?

We all know we can use tree to get a nicely formatted text "visualization" of the structure of a directory; say: $ tree -spugD /usr/include/boost/accumulators/numeric/ ...
1
vote
1answer
271 views

Run terminal commands from within LibreOffice's Basic programming?

Is there a way to run system commands in LibreOffice Basic macros so that macros will be able to do things outside LibreOffice (e.g. changing keyboard layout)?
2
votes
1answer
475 views

Convert xml subtitle file to srt format

I have a xml subtitle that looks like this: <?xml version="1.0" encoding="utf-8" ?><transcript> <Item from="1.16" duration="4.68"><![CDATA[(Dong-hyuk is coming to see you now.) ...
2
votes
1answer
102 views

diff two directories for changes and format output to use for script

I currently try to monitor two directories and subdirectories for changes in files. The directories contain the same set of files, some of them are changed. So I thought I might use the diff command ...
3
votes
1answer
83 views

Launch RDP silently?

I currently use the following command to launch an RDP session which works fine: rds@rds:~/Downloads/FreeRDP$ xfreerdp /v:farm.company.com /d:company.com /g:rds.company.com /f /u:username /p: At ...
2
votes
1answer
143 views

What is the difference between filename=${1:-/etc/hosts} and filename=/etc/hosts? [duplicate]

What is the difference between filename=${1:-/etc/hosts} and filename=/etc/hosts? For example: filename=/etc/hosts if [ -r "$filename" ] && [ -s "$filename" ]; then md5sum $filename ...
1
vote
1answer
230 views

Change a value in a config file, or add the setting if it doesn't exist?

When modifying config files from the command line, I often want to find the setting in the config file and modify that line if that setting exists. If that setting doesn't exist, I want to add it to ...
1
vote
3answers
214 views

How to read the file line by line and to print the previous line where the file contains a single token

For example my file is like: 59 6 18 2014 169 7 14 2 7671912 7849744 201 4 60 6 19 2014 170 5 49 2 7671912 7849744 201 5 61 6 20 2014 171 6 8 2 7671912 7849744 201 6 62 6 23 2014 174 5 3 2 7671912 ...
0
votes
2answers
75 views

Simple server that triggers script and responds

I need to have a very simple server running that can: Take rest call. It triggers a script when a call is made The script checks if database is running or not. If running then reply back to client ...
1
vote
1answer
27 views

How do I obtain the kill signal / message / reason within a script?

I am using the following trap: trap OnExit EXIT And in my OnExit function I would like to capture all the info I can on what happened so I can write it to a log file. Id like to know who, why, how, ...
2
votes
0answers
50 views

Remote script cleaning up

I run a remote script using ssh: local script: local_command ssh -p 222 user@server 'sh -s' < ./remote_run.sh remote script: some_command & sleep 10000 trap 'echo exiting' SIGINT SIGTERM ...
1
vote
1answer
95 views

Expect script: remove password on private key

I'm trying to remove the password on a private key. Doing it by hand is simple, I run this command and enter the password : openssl rsa <newkey.pem > newkey-no-password.pem I'm trying to do ...
2
votes
1answer
155 views

How to simulate user interaction when running another script

I am new to shell scripting. When I want to run a bunch of Linux commands I do fine, but how do I give user input when another script is called and asks for input while it runs. Here is the situation ...
0
votes
2answers
99 views

set variable options with dot

I'm trying to interface with a system not managed by me that is doing some Unix command scripts and command to easily execute a job. There is a variable substitution that doesn't work and I wonder if ...
3
votes
2answers
267 views

Variable assigned inside ssh command doesn't return proper value

I'm executing the below command in the ssh part of my script. The command is meant to cut the file size from ls option and storing it to a variable. Then print the variable: echo "Enter srouce file"; ...
2
votes
1answer
529 views

What is wrong with this code?

I have a script that goes like this: while : do Start_Time=$(date +"%s") MAIN PROGRAM GOES HERE (CROPPED TO SHORTEN THINGS) Run_Time=$(( $(date +"%s") - $Start_Time )) if [[ ...
2
votes
1answer
49 views

What does the period indicate when an environmental variable is set like “VARIABLE_NAME=.”

What does the period indicate when an environmental variable is set like VARIABLE_NAME=.
2
votes
4answers
511 views

How to initialize an array using awk and bash?

I am trying to store values of the first line of a text file into an array. Here is what I have so far: arr_values=() awk ' NR==1 { for (i=0; i<=NF; i++) ...
2
votes
4answers
278 views

Inserting a line in a file only if this line isn't yet part the file

Total newbie to shell scripting, I am searching to create a script to automatically apply some custom configuration to text based configuration files. In the present case, I am searching to add 2 ...
4
votes
2answers
130 views

Replace common values in two files according to first column

How do I replace common values in two files according to first column? I have file 1 (1.txt): CH063_01084 CH063_01083 CH063_13925 CH063_14473 and file 2 (2.txt): CH063_01083 FGSG_16349 4 ...
1
vote
1answer
91 views

Why isn't this XMLStarlet Query Working?

I'm trying to write a simple bash script that parses price info from the ebay developer API search results. Here's an example of XML search results for "Detective Comics 700": ...
3
votes
0answers
87 views

How to make a PAM substack “requisite”?

For the auth section of my PAM configuration, login and mdm etc. call common-auth. I have common-auth calling the following as a substack (as auth substack krb5ldap-cache-auth): auth optional ...
0
votes
2answers
46 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
54 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
32 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
1k 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
46 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
39 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
126 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
108 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
5answers
100 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
197 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
253 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
365 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
112 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
42 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
106 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
134 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
265 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
831 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
34 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
62 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
111 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
147 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
132 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
131 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
28 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
218 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 ...