A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.
5
votes
2answers
85 views
Walking through files in directory randomly
How to change for track in *.mp3; do so that all .mp3 files in the current directory are walked through but in a random way?
0
votes
1answer
34 views
Utility script framework
We have a couple dozen utility scripts that run on various machines to do things like application level backups, pruning out old data, cleaning up disk space, etc. They were written by multiple ...
3
votes
1answer
42 views
Script not getting executed as per expectation
I have two Perl scripts at a predefined location in Unix. This predefined location is set in path variable ($PATH). Now when i try to run first script (from any location) the script runs successfully ...
-3
votes
1answer
63 views
Rename two files [closed]
I would like to rename two files files by using a script.
E.g.
mv plugin-cfg.xml plugin-cfg2.xml
and
mv plugin-cfgbk.xml plugin-cfg.xml
I need to do this in multiple directories.
...
16
votes
1answer
277 views
How to move a directory, file by file? (instead of “copy then remove”)
My computer has one 500GB drive.
I want to move 400GB of data from /unencrypted to /encrypted.
Both directories are on the same partition, but /encrypted is handled by ecryptfs, so mv /uncrypted/* ...
1
vote
3answers
70 views
sed - how to replace a single quote?
This works fine:
sed -i 's# @driver.find_element(:xpath, "//a\[contains(@href,##' temp_spec.rb
against a source of
@driver.find_element(:xpath, "//a[contains(@href,'change_district')]").click
...
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
1
vote
2answers
63 views
How to monitor the last PID assigned by the kernel?
To monitor process creation I'd like to periodically write the last PID assigned by the kernel to any process on the system (not just processes created by the PID-monitoring program) with a time stamp ...
1
vote
3answers
49 views
How to share a GNU sed script between Linux and Mac OS X
I have a GNU sed script I use on Linux; it is installed at /bin/sed and it seems it contains GNUisms. I have collaborators using Mac OS X. They have installed (non-GNU) sed, located at /usr/bin/sed, ...
0
votes
2answers
67 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 ...
1
vote
2answers
62 views
Commands for determining level of usage of server
I am scripting a new program that will connect to a cluster of machines in a VM park, and hopefully check their level of usage.
The VM clients are a combination of RHEL and CentOS, and runs on ...
1
vote
3answers
39 views
Solaris: Script for finding the physical device path of all installed fiber cards
I have a number of systems (with quite varying type, generation and architecture unfortunately).
I need to create a list of fiber cards on these varying systems.
I am able to use prtconf -v, and ...
4
votes
3answers
87 views
How to constraint time a program runs in Linux?
I have several simulations to do, each is invoked with python simulate.py <parameter list>. The problem with these simulations is that some of them hang without quiting, which prevents me from ...
-1
votes
0answers
21 views
Creating a multicolumn test menu from a script
I would like to create a text menu from within a script.
I would like it to be multicolumn or a grid with multiple options for each entry.
Let me give an example:
Let us take the letters A-L and ...
2
votes
2answers
99 views
/usr/bin/env: zsh -: No such file or directory
I get the error
/usr/bin/env: zsh -: No such file or directory
...when I run an executable zsh script that starts with the following shebang line:
#!/usr/bin/env zsh -
Also, FWIW, replacing - ...
5
votes
4answers
143 views
Hybrid code in shell scripts. Sharing variables
This answer discusses how to run a multi-line Python snippet from the command line in a terminal. I noticed that the answer works great within shell scripts, even with nested indentation, which is ...
0
votes
1answer
78 views
Counting files on a remote server with ssh and an expect script
Below is my script to take count for files which are present in remote server.
But it is not working. Please help me.
#!/usr/bin/expect
spawn ssh sduser@172.0.0.2
expect "123"
send "123"
interact
...
-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 ...
2
votes
3answers
61 views
Scripting to domain allocation to server
I have two text files:
file #1: domain.txt
cocacola.com
airtel.com
pepsi.com
file #2: servers.txt
192.0.53.42 , 4 # 4 domains already allocated on server 192.0.53.42
192.53.1.2 , 1 # 1 ...
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
votes
0answers
50 views
shell scripts in linux [closed]
The "time and network" script
•Find the current time.
•If the current minute-of-the-hour is greater than 30, then use ifup to enable all network interfaces, otherwise disable all network interfaces ...
1
vote
2answers
45 views
Direct recursive shell script output to each subdirectory, not parent directory
I'm processing a batch of subjects data recursively, calling the script within the parent directory.
For example, I have the parent directory:
/home/subjects
and the subdirectories which contain ...
2
votes
1answer
41 views
Invoking a script with ld-linux.so?
I just downloaded a tar file that is supposed to include everything required to run a program that we can call some_binary. I extracted it's contents, and I see the following:
A binary (let's call ...
4
votes
3answers
70 views
CD into directory from HISTORY in a bash script or alias e.g. $(!!)
I often want to change into the directory of a file on my file system, but I'm not sure where the file is.
I search for it like so:
find -type f -name "myfile.txt"
Lets say for the sake of ...
1
vote
0answers
21 views
rsstail Not Printing Output
I've installed rsstail 1.8 on my linux box and everything seems to be going smoothly, knock on wood, except for the part where rsstail isn't printing the streams. Running the command, I see that it's ...
2
votes
1answer
98 views
Script to check a folder, print the files then delete those files
I am looking for some guidance on creating a script that will check a specific folder, print all documents (if any) and then delete those documents. I would also like to run this script as a cron job. ...
5
votes
5answers
202 views
How to remove multiple blank lines from a file?
I have some text-files I use to take notes in - just plain text, usually just using cat >> file. Occasionally I use a blank line or two (just return - the new-line character) to specify a new ...
2
votes
2answers
76 views
What scripting language can I use to automate a concatenation & zipping process?
For a project I'm doing I need to concatenate and compress (with zip) many (midi) files and compare their sizes. I've thought there must be some language that allows me to do something like this:
...
1
vote
1answer
63 views
Why ssh -nq -t can't see my environment variable?
I am executing a command on remote machine with -t flag ( to prevent the command from 'blocking' ) the prompt (somehow it works that way). So I am using ssh -nq -t root@ip but with this, the script ...
0
votes
1answer
50 views
How to get the arguments to a php function via grep?
I am writing a script to let me know the database login info for each PHP-based web site on a server that I am migrating. The login information is usually done either like this:
...
0
votes
1answer
30 views
While setting up SFTP between *nix servers, is the intial handshake optional?
I setup SFTP between *nix servers as follows:
Generate the Public key on the sending server by running the below command:
[user1@server1] $ /usr/local/bin/ssh-keygen -t rsa -b 1024
Then copy ...
2
votes
1answer
41 views
Bash: pair up two series of files
I have a number of files with this pattern:
file1_foo.ext
file1_bar.ext
file2_foo.ext
file2_bar.ext
and so on.
I need to "pair them" and put them in a file like this
file1_foo.txt ...
3
votes
1answer
140 views
Increase %e precision with /usr/bin/time shell command
When I run the time command in shell time ./myapp I get an output like the following:
real 0m0.668s
user 0m0.112s
sys 0m0.028s
However,when I run the command \time -f %e ./myapp I lose ...
0
votes
2answers
96 views
Ubuntu crontab php not working
Yes, I have read many, many documentations but I can't get it to work. I have a simple single php file which I want to run once or twice in a minute. My php file is called: cronjob_refresh.php and I'm ...
1
vote
1answer
115 views
Replacing Evernote with Emacs and markdown - .org file list
I have grown tired of using evernote with wine or with any of the linux clients. I decided to change to Emacs and write all my notes in markdown so I can easily publish them in HTML and sync them with ...
0
votes
2answers
96 views
Automated ssh-keygen without passphrase, how?
I would like to make an automated script that calls ssh-keygen and creates some pub/private keypairs that I will use later on. In principle everything works fine with....
ssh-keygen -b 2048 -t rsa -f ...
2
votes
1answer
44 views
How would a script know when running locale-gen is necessary?
One of the basic steps in setting up a new system is getting the right glibc locale files generated. At least in ArchLinux and Gentoo, one is expected to do this step by hand. I am trying to setup a ...
3
votes
1answer
42 views
How to edit files in-place while performing operation on the values matching the searched pattern?
Given a list files containing random text and many datetimes in ISO format in it (e.g "2012-07-02T10:47:24+02:00"), how can I find all these datetimes and add 2 hours to each one ?
Ideally a solution ...
1
vote
2answers
40 views
Automate input procedure to a binary file
I have a binary file on Unix, which when executed asks the user for inputs. The inputs to this binary file are given manually. I want to automate the procedure, since I know the inputs already. I ...
1
vote
1answer
118 views
Securely reading and parsing a string from a parameter or file in bash
I've been writing a number of bash scripts lately which get variables from a parameter or from a file. Some of the scripts run as root (using sudo)
This is on my notebook, so there aren't any other ...
3
votes
1answer
96 views
Searching for Failed attemps in /var/log/secure
I'm currently writing a script to examine /var/log/secure file and report how many failed attempts there were that day. I need to output it in the following format:
Date: 03/15/10 Time: 10:30 Number ...
0
votes
1answer
153 views
How can I find and filter a specific column in a .csv file? [duplicate]
I have .csv files with the following structure:
cat,dog,mouse,pig,bird,cow,...
21,34,54,566,78,1,...
23,10,12,569,56,4,...
32,20,13,123,56,3,...
34,30,44,322,66,2,...
I want to filter the column ...
3
votes
3answers
155 views
Split PDF into documents with several pages each
There are several resources on the web explaining how one can split a PDF into many files with on page per file.
But how can you split them into chunks of, say, five pages each? I have looked into ...
1
vote
1answer
38 views
Sort aligned columns
I have a program which output looks like this
# Status VAL1 VAL2 Description
1 some text 2.5 4.4 Some long other text
5 some text 2 14.5 2.0 Some long other ...
1
vote
4answers
104 views
Where to put a background script
I have a script that i want to be constantly running in the background but I don't know where to launch it from
If I put it in .bashrc it will run multiple times (one for each login)
It's an ...
0
votes
0answers
32 views
A simple script to make a desktop version of Nimbuzz WebChat? [closed]
There is a nice little script which uses python-webkit called "RGB/HEX Color Picker" here: http://gnome-look.org/content/show.php?action=content&content=128317
I tried if I can use it to make a ...
2
votes
1answer
244 views
Create sub-directories and organize files by date
I have some directories of files copied from my security camera that I would like to organize into sub-directories by file date. So for example;
-rwxrwxrwx 0 root root 4935241 Jul 19 2012 ...
1
vote
2answers
116 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 ...
6
votes
5answers
467 views
How can I have more than one possibility in a script's shebang line?
I'm in a bit of an interesting situation where I have a Python script that can theoretically be run by a variety of users with a variety of environments (and PATHs) and on a variety of Linux systems. ...



