Tagged Questions
0
votes
1answer
65 views
Use of .. in Linux scripting and makefiles [closed]
what is the use of .. in linux scripting and in the following makefile?
MODULE =
EQUALIZER = ..
SRCS =
include ${EQUALIZER}/xyz.mak
include ${EQUALIZER}/pqr.mak
0
votes
2answers
70 views
How to create as many variables as needed from shell script(bash)?
I'm making a script for monitoring some user processes with Upstart but, since its for the company I work for, they asked me to do it generic...how's so?
Well, the number of processes being monitored ...
-5
votes
0answers
46 views
Linux Bash Script [closed]
I am currently in need of a simple Linux script which provides a menu to any user, where they are able to either add or delete a user, where if they choose to add the user they can do so via a text ...
1
vote
1answer
75 views
How to clone a read-only portion of /proc file system
The problem with reading /proc file system is that it is not atomic. I tried using a library (procfs in Python) that wishes to read it, but it has glitches about 5% of the time because the process ...
0
votes
2answers
56 views
Executing a program according to the last modified date
I need to write a script which would execute some executables in a directory according to the last modified date. The oldest should run first. How do I do it?
This is what I have done so far
for f ...
1
vote
2answers
117 views
find total ram memory and swap memory
I need to write a script to find total memory and total swap of several linux server (2000+).
I have one trusted server from where I can login to all these 2000 servers without a password.
When I run ...
2
votes
1answer
107 views
bash scripting add arguments
I have created a script which takes parameters and arguments. I want to insert the --help argument.
I already know how to parse normal arguments with -, but I don't know how to parse the -- ones.
to ...
10
votes
2answers
287 views
Shebang line with `#!/usr/bin/env command --argument` fails on Linux
I've got a simple script:
#!/usr/bin/env ruby --verbose
# script.rb
puts "hi"
On my OSX box, it runs fine:
osx% ./script.rb
hi
However, on my linux box, it throws an error
linux% ./script.rb
...
5
votes
4answers
252 views
Testing, from a script, if audio devices are in silent?
Is there a default program where I can check if my audio devices are in silent?
Edit: By silence, I mean that if there is something playing on that (not just activated or opened)
Something like ...
6
votes
3answers
399 views
Difference between commands in bash script and commands in terminal
Are there any differences between commands that you type into the terminal and commands you include in a script?
2
votes
1answer
127 views
Access the Shift-Insert clipboard from script
How do I access the Shift-Insert (paste) clipboard from a script? You can see what I use here.
Edit: A demonstration how it works, with xclip:
echo hello | xclip -selection secondary
xclip -o ...
1
vote
3answers
103 views
Script to insert line into files in sub-dirs
I have a sub-dir tree with varying number of branches and most of
the branches contain .cpp files (many of them). I have a header-file
at the root of the tree that I want to have as a
#include ...
1
vote
2answers
242 views
Concatenate multiple files under subdirectories
My directory structure is given below
x:\Project_2012-158A\Sample_4041
SampleSheet.csv
4041_CGTACG_L002_R1_001.fastq
4041_CGTACG_L002_R2_001.fastq
4041_CGTACG_L006_R2_001.fastq
...
1
vote
4answers
482 views
Checking if a file exists in several directories
I've been working on this far too long and need some help.
I need a script that will look at files in a directory and see if it exists in one of several directories.
I need something like this:
for ...
1
vote
1answer
253 views
Extract binaries from pcap using command line (script)
As the title says, I'm looking for a way to extract binaries from PCAP's using the command line. I realize it is possible using Wireshark -> File -> Export -> http objects etc. But tshark doesn't seem ...
3
votes
1answer
92 views
How can I script the creation of a single partition that uses the entire device?
I am specifically using this to partition and mount EBS volumes on Amazon EC2 instances, but really this should be generally applicable to initializing any new drive.
As the question says I want to ...
1
vote
2answers
445 views
Fetch values from plist file on Linux
I have bash script which was written for OS X and now ported to Linux. I don't have access to the Linux box. The bash script would read values from plist files using the defaults read and PlistBuddy ...
2
votes
3answers
136 views
What is the difference between ./script and . ./script? [duplicate]
Possible Duplicate:
Using ‘.’ to execute files in bash
I was trying to figure out how to export my environmental via script instead of changing my .bashrc file.
I found this old useful ...
2
votes
1answer
227 views
Download file linked in MySQL DB, extract text and insert into db with bash script?
I want to download a file (only download if the url ends with a certain string), which URL is in a MySQL database, extract the text and write the text to the database, by replacing the url.
And this ...
1
vote
0answers
367 views
Quickly check whether many network hosts are up-and-running
Objective: check if a host is up-and-running on the network,
with a method that can be efficiently parallelized over many hosts.
Emphasis on a QUICK turnaround of the check.
Reason to emphasise ...
14
votes
6answers
1k views
The most universal scripting language for Linux is?
We are writing scripts for Linux systems, there has been some debate over what would be the most universally Linux present scripting language to use. Bash, SH, Posix? What?
4
votes
2answers
250 views
Semicolon in conditional structures
Why put semicolons in one and not in another?
The result is the same
Code one
if [ "a" == "a" ]
then
echo "true"
fi
Code two
if [ "a" == "a" ];
then
echo "true";
fi
Semicolons in the second ...
2
votes
0answers
203 views
Can capabilities be used in scripts without setcap'ing the interpreter binary?
Right now I'm using cap_net_bind_service MY_USERNAME in /etc/security/capability.conf.
Now I just need to set cap_net_bind_service+i on the interpreter of my favouite scripting language to be able to ...
4
votes
1answer
73 views
Transform directory structure
I have the following folder structure
root folder
|-al2
|- GER.zip
|- ENG.zip
|-ww
|- GER.zip
|- ENG.zip
and so on. The folder names are random strings.
I want to sort the files in ...
11
votes
1answer
1k views
Making a progressbar with “dialog” from rsync output
I'm looking for a way to filter/redirect rsync output in a manner where it can be fed to the "dialog --gauge" command, so I can get a nice looking progressbar during file sync.
Currently I have only ...
0
votes
2answers
90 views
HDI script fixed (non-interactive) input in a command-line gui program?
I want to create a simple script that initiates a simple gui-based program (think ncurses-style, text-based graphics in a shell) in Debian. I only access the server through SSH, so I can't do ...
3
votes
2answers
135 views
Exiting a pipeline if a former command fails
I'm trying to check the number of running and queued PBS jobs by parsing the output of qstat -tn1 from a bash script.
So far, this has worked:
count ()
{
qstat -tn1 | awk '
BEGIN { R = 0; ...
5
votes
2answers
560 views
How to tweet using terminal?
I would like to tweet a message using terminal.
I tried something like:
curl -u 'TwitterUsername':'TwitterPassword' -d status=”Your Message Here” https://twitter.com/statuses/update.xml
but seems ...
1
vote
4answers
292 views
Is learning a text editor like vi necessary and still worth the time today? [closed]
I started a new internship where all the servers run on AIX. Logging in for the first time I was suprised to see that my favorite text editor nano was not installed.
Everyone here uses vi not ...
1
vote
2answers
273 views
Bash script to ftp only files of type gz in current directory
I have a bash script that cd to the right directory then uses the mput command to ftp all the files in the directory to a remote server, as below:
for from_dir in $DATE_LIST
do
cd ...
1
vote
2answers
1k views
How can I trim the carriage return from text that is being piped in bash?
I'm using this command to get my last typed command:
history | cut -c 8- | tail -n 2 | head -n 1
It works very well in bash, removing the line numbers, but there is one problem I have with it, (er, ...
4
votes
3answers
742 views
In linux, would it be possible to run a script every day 3 minutes later than the previous day?
My first solution to this was to execute date +%Y%m%d%H%M and put that format of numbers into a file, and run the script every minute from cron. Then if the date from the file matches the date ...
3
votes
2answers
411 views
How can I force a bash loop to end if it runs x times in x seconds?
I'm trying to grab batches of input from a remote pipe via ssh. My script below works ok, but I would like to add some sort of check into it so that if something were to go wrong or break the loop ...
0
votes
2answers
570 views
Need help to make rows into column with awk or sed
Recently, I look for scripts to take this:
This;
Is;
First;
Line;
and make it like:
This Is First Line
0
votes
2answers
1k views
How to calculate in linux number of file inside nested directories?
I need to extract information how much files are in some directory tree:
/.../testRoot/test1/test11/..../file1
/.../testRoot/test1/test11/file2
/.../testRoot/test1/test11/..../file3
...
0
votes
1answer
545 views
Why isn't /etc/rc.local executed when I log in?
I'm trying to run a script at login, and this is the way I've found to do it.
I'ved edited /etc/rc.local with a line such as bash /home/me/script.sh.
I've made that script executable.
It doesn't ...
4
votes
1answer
218 views
Efficient way of comparing in awk
#!/bin/awk
BEGIN {
while(getline var < compareTo > 0)
{
orderIds[var]=var;
}
}
{
if(orderIds[$0] == "")
{
print $0;
...
4
votes
1answer
358 views
Giving a custom script root permissions
I have a backup drive that is Truecrypt Encrypted. I'd like to automnt this drive so I can automate backups when in the office. I am using Linux Mint 12 x64bit
I wrote a script that runs successfully ...
4
votes
4answers
1k views
How to perform a sed in-place substitution that only creates backups of files that were changed?
I ran the following to replace a term used in all files in the current working directory:
$ find . -type f -print0 | xargs -0 sed -i'.bup' -e's/Ms. Johnson/Mrs. Melbin/g'
This performed the word ...
1
vote
2answers
135 views
How to log if an environment variable is unset? [closed]
How can I write a shell script that checks for an environment variable and writes to a log file if the variable is unset?
Also, if the file name pointed by env variable doesn't exist, how to create ...
3
votes
1answer
412 views
Change screen “hardstatus” color dynamically
I show the hard-disk free space in hardstatus screen. But also I want change the color of this value when it's less than a value to alert me.
I have done a script that it checks this and it returns a ...
0
votes
1answer
390 views
What does “sudo chown -R hadoop:hadoop hadoop” do?
I saw the following script, posted online, that was used during the hadoop installation process.
sudo tar xzf hadoop-0.20.2.tar.gz
sudo mv hadoop-0.20.2 hadoop
sudo chown -R hadoop:hadoop ...
1
vote
1answer
168 views
Mass update of /etc/ldap.secret
I have a group of servers authenticating against an LDAP server. I would like to be able to periodically update the /etc/ldap.secret file with an updated secret. I've written a small script that reads ...
5
votes
4answers
1k views
Copy a File From One Zip to Another?
I have a file named 'sourceZip.zip'
This file ('sourceZip.zip') contains two files:
'textFile.txt'
'binFile.bin'
I also have a file named 'targetZip.zip'
This file ('targetZip.zip') contains ...
4
votes
1answer
743 views
Bash script IDE
Is there a bash/ksh/any shell script IDE.
Don't you get annoyed when you forget the space inside if or I don't know, some minor syntax mistakes you do from time to time, but takes you a long time to ...
5
votes
1answer
1k views
Bash flush standard input before a read
Is there an easy way in bash to flush out the standard input?
I have a script that is commonly run, and at one point in the script read is used to get input from the user. The problem is that most ...
5
votes
1answer
598 views
Batch importing .sql files
I have a bunch of .sql files in a directory that I need to import. Although I can do it manually, for scripting purposes I need to be able to apply them in bulk. How can I do that though? What ...
3
votes
1answer
721 views
Read space as input in shell script
How can i give space " " as input in shell script ?
Ex :
echo " Enter date for grep... Ex: Oct 6 [***Double space is important for single date***] (or) Oct 12 "
read mdate
echo $mdate
In this i ...
2
votes
3answers
1k views
Bash eval array variable name
Here is my bash case:
First case, this is what I want to do "aliasing" var with myvarA:
myvarA="variableA"
varname="A"
eval varAlias=\$"myvar"$varname
echo $varAlias
Second case for array variable ...

