Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.).
0
votes
1answer
26 views
Copy a file from a remote server to windows home using scp
Is there a way to copy a file from a server to a local folder (i.e. My Documents)? can it be done by scp?
I have this script that generate some list. I want this script to automatically copy the ...
2
votes
1answer
20 views
Exit status on core dump
When a process dumps core, does it set any particular exit code? Alternatively, is there a way to detect if core was dumped in a shell script.
I have shell script that fires a job which occasionally ...
1
vote
1answer
19 views
Compare file size of multiple files in an array
Scenario:
Ftp site has 100s of files. Once a day, all the .gz files are copied to an AWS site then renamed. Only the date is kept in the file name.
Some of the files corrupted during copy.
A txt ...
2
votes
2answers
41 views
How to escape spaces etc in passed variable, for system call to cp in awk
As the title suggests, this problem has enough layers of complexity to make simple escaping characters difficult for me. I have a bash script which, for a large part, has an embedded awk script that ...
2
votes
0answers
22 views
Tmux log output [duplicate]
Im looking for a solution to an issue regarding tmux. One of my scripts ns2server stopped working recently when running start (using tmux) but not in debug mode (not using tmux).
I found that using ...
4
votes
4answers
251 views
Delete spaces, hyphens, and underscores in filenames?
What is a good command to delete spaces, hyphens, and underscores from all files in a directory, or selected files?
I use the following command with Thunar Custom Actions to slugify filenames:
for ...
2
votes
2answers
39 views
Replace value within single quotes in a line that contains certain word using sed command
I have a line as below in a html file,
shahar.push(['remoteUrl', 'staging.zazzercode.com']);
Depending upon environment, I want to replace the remoteUrl value with sed command.
eg,
...
2
votes
3answers
67 views
Script for testing SFTP login status?
I need to perform an automated backup task that connects to an SFTP server. The first stage involves testing the server connection by connecting to it. To be absolutely sure that it is connecting to ...
1
vote
2answers
50 views
How to add words to an existing column
I have a tab delimited file with 10 columns and in one of the columns (with about 40 million rows), I would like to add a word before the existing entry in each row (same word in each row!) and a ; ...
6
votes
3answers
135 views
Attempted assignment to non-variable?
We can use arithmetic operations inside shell script function:
function mess
{
if (( "$1" > 0 )) ; then
total=$1
else
total=100
fi
tail -$total /var/adm/messages | more
}
I ...
1
vote
2answers
65 views
Pass a command to ROOT from a shell script and having it stay open
I am writing a bash script to perform some analysis using the program ROOT. I want to run some initial command to load the result of the analysis, then continue using ROOT interactively.
The analysis ...
0
votes
1answer
59 views
Launching a program and executing a command in bash script [on hold]
How can I execute a command inside ROOT that I launch within the bash script? My aim is to have ROOT execute its GUI file browser and have it open if the user does not interfere with keyboard ...
-1
votes
0answers
42 views
Generating random numbers from users input [on hold]
I am trying to generate a one time random password from the user's input which i will be storing in a txt file for record keeping.
Here is the code:
#!/bin/bash
echo "Enter your string here"
read ...
0
votes
1answer
37 views
Combining multiple functions into a single bash script
Is there a way that I can combine the following commands (the last is a zsh function) into a single bash script?
find /path/to/directory/*/* ! -name "*.js" -type f -delete
find ...
4
votes
4answers
55 views
Renaming multiple files with rename
I need help renaming files in batch--the other questions I browsed don't exactly address my problem. The names of my files are generated non-deterministically, so I can't predict what they will be ...
0
votes
0answers
11 views
How to capture INFORMIX DB errors in shell script?
I need to capture the informix DB errors like Update failed, Insert failed using the shell script. I am using ksh shell.
5
votes
1answer
91 views
Multi-Threading/Forking in a bash script
I have written a bash script which is in following format:
#!/bin/bash
start=$(date +%s)
inFile="input.txt"
outFile="output.csv"
rm -f $inFile $outFile
while read line
do
-- Block of Commands
...
4
votes
3answers
51 views
How to put the output of the trailing lines of grep in on-line?
Assuming that I have this file:
Thu May 8 15:32:07 2014
User-Name = "Mark"
Framed-IP-Address = 0.0.0.0
Acct-Status-Type = Interim-Update
Acct-Input-Octets = 95684
...
3
votes
1answer
27 views
How do I parse a string in bash into variables using a tab as the delimiter and preserve spaces?
I am in the process of writing a bash script to display various statistics, some of which come from a MySQL database. The pertinant code I'm having difficulty with is:
read min max rows <<< ...
0
votes
1answer
54 views
Command not working in shell script, but works on command line
I have a shell script that executes the following command:
bash -c "screen -dmS node /home/nodejs/bridge/bridge.js"
However, the screen is not being started. Typing the command...
screen -dmS node ...
3
votes
2answers
81 views
Unable to pass a bash variable as a python argument in bash
For some reason I cannot pass the bash variable $FOLDER as a python argument on the following code. The python script downloads some files from amazon s3.
Bash script:
#!/bin/bash
FOLDER=$(./aws get ...
0
votes
1answer
25 views
Mandatory argument for script to run java program
My script is called: report_startDate
It has the following line:
$JRE_ROOT/bin/java -cp /home/me/report/config/:/home/me/report/jar/reporting-1.0-SNAPSHOT.jar com.me.project.report.Main $1
$1 ...
3
votes
1answer
43 views
grep upto matching brackets
I have a file like this:-
pin(ABC) {
a b c d e f {
abc
}
}
pin(XYZ) {
g h i j k {
j k {
...
2
votes
0answers
28 views
background gui process in shell script
In the below script, ivfstudio commands open a gui.
Even launched as a background process, I need to close it first so that the next commands are executed. How to make it "really background" ?
...
3
votes
1answer
61 views
two if conditions in for loop bash scripting
I've trying to make two if conditions in for loop. Is it possible this? Now doesn't return anything from second if only two OK from first if.
#!/bin/bash
servers=("212.39.82.157" "212.39.82.157" ...
1
vote
2answers
15 views
rename a batch of files after reading from a source file
I have a directory full of over a thousand files and the names are bit long (and no pattern found in the naming style). I would like to simplify the filenames. E.g.:
...
2
votes
2answers
32 views
Read Multiple Entries from an Input File
I wrote a program in Fortran that asks me for latitude and longitude and the name of the output file every time I run it. It works great. What I have been meaning to do is run this program for the ...
0
votes
1answer
27 views
What is the term “Usage”?
I am seeing this a lot in the scripts. Is "usage" a command in unix ?
I tried googling it but got ambiguous results. Here is an example : ${1?"Usage: $0 ARGUMENT"}
0
votes
1answer
24 views
Connect psftp between Unix and Windows server
I need to transfer files from Unix to Windows server. After creating a folder in the windows server files need to be copied from Unix to Windows. I am using psftp to do this process.So, I am trying to ...
0
votes
1answer
39 views
How to evaluate a variable length in shell script?
I want to write a shell script, in which it will call different command according to the variable length. But I didn't figure it out yet.
My unwork script is here:
for i in n5 n25
if ${#i} == 2;
...
-2
votes
1answer
39 views
Installation script for OpenERP, creating directories under /var
I would like to know what this code means. I found it on the OpenERP forum. It is supposed to run on Linux CentOS.
adduser openerp
DIR="/var/run/openerp /var/log/openerp"
for NAME in $DIR
do
if [ ! ...
-2
votes
0answers
28 views
using mysqlimport on a large amount of csv files in a directory via bash scripting [closed]
I have a directory with approximately 75 csv files in it that I need to mysqlimport into a MySQL database. The MySQL database does not have the tables created.
The files:
* The data is all numbers
...
1
vote
1answer
25 views
How can I use global variable arrays in aliases or functions
I am attempting to simplify repetitive work procedures. In doing so, I am trying to write a .bashrc script which will set global path variables that aliases can refer to. Disclaimer: I'm new to linux ...
1
vote
0answers
46 views
How to properly start and stop shell script in linux, busybox?
I am trying to write a small shell script that would send some commands to my tv set from my set top box that has busybox on it. The problem is that it generates huge amount of zombie processes, and ...
0
votes
2answers
42 views
How to kill a process in shell script which is running through cron?
I have a shell script which runs in cronjob. This shell script has to kill a process which is running and start the new process again.
When I run the script manually it works perfectly fine, but when ...
-4
votes
3answers
60 views
Birthday reminder
write a bash shell script to get the alerts of friend's birthday
Suppose
Birthday Date Friend's name
08-02-2014 : Prashant
08-15-2014 : prabhat
09 -16 -2014 ...
2
votes
4answers
95 views
Change to the last modified subdirectory of the current directory
I have an application which generates a couple of files in different directories at a regular interval and I need to check the latest files generated, i.e. the file which is generated in the most ...
0
votes
1answer
45 views
Writing a Bash script to run and end at specific times
I'd like to create a script that will do the following. Start at a given time during the day and end at another given time.
So for example, I have a program I'd like to test, so my script would be ...
-1
votes
1answer
19 views
A command showing if I have the right to perform writing?
I'm searching for a command which only says if the current user has r-rights (read) on the file passed as a parameter.
This command could be something like haveIRights -x <file> and it has to ...
8
votes
1answer
143 views
How to append multiple lines to a file with bash, with “--” in front of string
Question very similar to How to append multiple lines to a file with bash but I want to start the file with --, and also append to the file, if possible.
printf ...
2
votes
3answers
53 views
moving a (file | directory) while avoiding filename collisions
I have a bash script that moves files from a number of different locations to a folder named completed.
I want to avoid overwriting previous files, so in the case when the name of a file (for ...
2
votes
3answers
33 views
waiting for network in a bash script
I'm running a script that relies on network being up and a network share be mounted. The script runs on login (which happens automatically after boot). The problem is that by the time the script runs, ...
3
votes
0answers
17 views
Get notified from avahi
After looking for a zero-conf browser valid implementation I realised that inside my linux machine (ubuntu) I already have avahi and typing:
avahi-browse -alr
I get a complete list of all devices ...
8
votes
6answers
379 views
How can I test if a variable is empty or contains only spaces?
The following bash syntax verifies if param isn't empty:
[[ ! -z $param ]]
For example:
param=""
[[ ! -z $param ]] && echo "I am not zero"
No output and its fine.
But when param ...
0
votes
2answers
58 views
Unix Shell Scripting output to an Excel File
I have a Shell script with Multiple SQL statements like this:
select Count(*) from Emp where date= current_date-1;
After executing the Shell script i need a MS excel file to be create with Column ...
2
votes
3answers
93 views
Count files in a directory by extension
For the purpose of testing, I'd like count how many images files are inside a directory, separating each image file type by file extension (jpg="yes". This because later it will be useful for another ...
1
vote
1answer
15 views
Make some fields required in dialog
The script below creates a dialog box. The user can press Enter at any time, and then the script continues. I need to block the Enter key to ensure that the user fills all the fields. How can I do ...
2
votes
0answers
35 views
Running shell script inside with vagrant provision
I have setup a vagrant box using precise64 (ubuntu 14.04) and installed packages needed for octopress. I can ssh into the vagrant box and generate posts and run preview for my octopress site.
Now I ...
4
votes
1answer
113 views
Proper way to distribute shell scripts
What is the most proper way to distribute shell scripts, if behaviours of shells can be modified by set and thus are unpredictable?
For example, rm *.txt wouldn't be executed as expected on the ...
-1
votes
0answers
54 views
Unique id for combination of Latitude - Longitude
I have a LibreOffice Calc table containing one column with latitude and one with longitude. What I want to do is for every unique combination of latitude and longitude a unique number to be assigned ...