A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.
0
votes
1answer
22 views
Reusing user input in a script
I have the following script which works:
#!/bin/bash
xfreerdp /cert-ignore /f /v:farm.company.com /d:company.com /g:rds.company.com /u:$(zenity --entry --title="Username" --text="Username") ...
2
votes
2answers
27 views
Pass argument to script, then redirect script as input to bsub
I am currently working with the bsub job submission system from Platform LSF. I need to submit job scripts, but I am running into a problem with passing arguments to the job script.
What I need is as ...
3
votes
1answer
39 views
Run command based on output of another command
OS: AIX 7100-04-1216
So basically I'm trying to write a for loop that sees which volumegroups I have on my system, which filesystems reside in those volume groups and what the size of each of those ...
0
votes
2answers
96 views
If UID=1000 continues, else exit
I am wondering how to implement the following in a bash script.
if UID=1000, continue
else exit
confirm choice (y/n)
3
votes
1answer
97 views
Converting and rescaling a lot of png images to jpeg
I have a lot of .png images in a folder. Is there a command (or software) that can convert all them to .jpg and (simultaneously) rescale the created .jpg files to 25% of their original size?
2
votes
3answers
54 views
How to add a new line for a missing entry between two fields
I have this file. As you can see in column1, entries TEST01N03, TEST01N06,
and TEST01N18 are missing (total of 18 entries).
Is there a way to check the fields of this column and fill in the missing
...
1
vote
1answer
36 views
Why does the same sed regex (after grep) fail when run in a bash script vs bash command line?
Here's the script. It is successful when I run it from the BASH prompt, but not in the script. Any ideas?
When I say "fails," I mean the sed regex doesn't match anything, so there is no replaced ...
0
votes
3answers
52 views
How to count number of instance of a word starting at another word
I need to grep the MySQL-error log starting at today's date formatted like:
`date +"%y%m%d"` (140710)
And look for all instances of the word partitioned.
I've tried various things to no avail. ...
1
vote
1answer
38 views
How to run java service as a non-root user on CentOs 6
I have a script that starts a Java application as a service on CentOS 6:
#!/bin/sh
# chkconfig: - 80 20
SERVICE_NAME=cn4server
PATH_TO_JAR=/usr/local/share/myserver/cn4server.jar
...
1
vote
0answers
4 views
How can I run a KDE plasma script from command line without GUI?
I want to run a plasma JavaScript file from command line, but the only solution I found so far involves a graphical script editor and requires a user interaction to run the script:
qdbus ...
0
votes
1answer
38 views
Converting windows date logic into Unix [closed]
I had coded the below logic in Windows batch scripting and I need to replicate the same in Unix.
# Calculating Yesterday's Date
for /F "tokens=1-4 delims=/- " %%a in ('date/T') do set DY=%%c
for ...
1
vote
2answers
56 views
SCP Automation in production environment [duplicate]
I want to implement the use of scp command in a production environment. I don't want to provide my password in the automation script.
Is there any way?
I need step by step solution.
1
vote
2answers
67 views
Shell Script - how to scp into remote server and download files and protect password
I have a remote server that I need to download Apache logs from.
I can manually scp into the server and get the files, but I'd like to put this in crontab. The only way to automate it is to include ...
1
vote
1answer
32 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
1answer
22 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
1answer
31 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
32 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
93 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
43 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
40 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
131 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
44 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
167 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
27 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
23 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
35 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
30 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
38 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
77 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
73 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
518 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
46 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
110 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
233 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
99 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
38 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
29 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
25 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
44 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
28 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
207 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
37 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
55 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
56 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
79 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
34 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
136 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
224 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
45 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 ...