I have a script which will be run interactively by non-technical users. The script writes status updates to STDOUT so that the user can be sure that the script is running OK.
I want both STDOUT and STDERR redirected to the terminal (so that the user can see that the script is working as well as see if there was a problem). I also want b...
Some servers only support ftp to upload files.
When I export the a project from my subversion repository to my windows machine, all (linux) symlinks are replaces by placeholder-files:
link ../www_public/images
after uploading the all exported files I now use
find | xargs grep -P ^link
to find all those placeholders. I then repla...
I recently started using vim 7 (previously vim 6) and the smartindent setting. For the most part, it works well, though I'm so used to typing a tab after an open brace that it is almost counter-productive.
However, there is one piece of maniacal behaviour. When editing a shell script, I try to create a comment at the current indent le...
I want to execute something in a linux shell under a few different conditions, and be able to output the execution time of each execution.
I know I could write a perl or python script that would do this, but is there a way I can do it in the shell? (which happens to be bash)
...
I've written a script to backup my server's HD every night. At the end of the script, I sync, wait a couple of minutes, sync and then I issue sg_start --stop to stop the device. The idea is to extend the lifetime of the device by switching the HD off after ten minutes of incremental backup (desktop disks will survive several thousand on/...
I basically want to kill a whole process tree. What is the best way to do this using any common scripting languages. I am looking for a simple solution.
...
I have a script that calls an application that requires user input, e.g. run app that requires user to type in 'Y' or 'N'.
How can I get the shell script not to ask the user for the input but rather use the value from a predefined variable in the script?
In my case there will be two questions that require input.
...
I have lots of home directories under /ifshome on Linux. I want to see which users have not logged in for the past 6 months, and my solution is to parse the /ifshome/user/.lastlogin file. Each .lastlogin file has the same format, 1 line:
Last Login: Fri Mar 09 18:06:27 PST 2001
I need to build a shell script that can parse the .lastlo...
I wish to have long and short forms of command line options invoked using my shell script.
I know that getopts can be used, but like in Perl, I have not been able to do the same with shell.
Any ideas on how this can be done, so that i can use options like:
./shell.sh --copyfile abc.pl /tmp/
./shell.sh -c abc.pl /tmp/
In the above, bo...
The following code gives
[: -ge: unary operator expected
when
i=0
if [ $i -ge 2 ]
then
#some code
fi
why?
...
I have a pair of shell programs that talk over a named pipe. The reader creates the pipe when it starts, and removes it when it exits.
Sometimes, the writer will attempt to write to the pipe between the time that the reader stops reading and the time that it removes the pipe.
reader: while condition; do read data <$PIPE; do_stuff; done...
Looking for a solution in bash (will be part of a script).
Given a filename in the form "someletters_12345_moreleters.ext", I want to extract the 5 digits and put them into a variable.
So to emphasize the point. I have a filename with x number of characters then a five digit sequence surrounded by a single underscore on either side th...
i want to write a script to manipulate the dhcp.conf file. which in the sense, it has to read the file and it should ping all the lease IP and should give another text file, in which it should give the list of IPs, which devices are now existing.
EDIT: thanks for your swift reply. dhcpd.conf file is like this
lease 172.31.0.10 {
some...
I have a file 'records.txt' which contains over 200,000 records.
Each record is on a separate line and has multiple fields separated by a delimiter '|'.
Each row should have 35 fields, but the problem is one of these rows has <>35 fields, i.e. <>35 '|' characters.
Can someone please suggest a way in Unix, by which I can identify the r...
I am looking for a command that will accept as input multiple lines of text, each line containing a single integer, and output the sum of these integers.
As a bit of background, I have a log file which includes timing measurements, so through grepping for the relevant lines, and a bit of sed reformatting I can list all of the timings in...
From my bash shell I would like to call a program n times with a different numbered parameter, which has to be in a fixed format like "%02i"
One way would be:
for ((i=23; i<42;i++)); do
sh ../myprogram `printf "%02i\n" $i`
done
Is there a way to improve the printf.. part? I believe this might be a performance bottleneck with mor...
I'd like to script printing of a series of photographs, but to exact dimensions. (e.g. all jpegs in dir /tmp/printing, at 1.5" x 1.0", 6 to a page)
I happen to have my hands on a Ubuntu Linux box and a deskjet printer (hp5150) but could probably use Windows or possibly get another printer if absolutely required.
I'm reasonably familiar...
I have a list/queue of 200 commands that I need to run in a shell on a Linux server.
I only want to have a maximum of 10 processes running (from the queue) at once. Some processes will take a few seconds to complete, other processes will take much longer.
When a process finishes I want the next command to be "popped" from the queue a...
Hi,
I store the SQL script for a particular release in a subdirectory of 'scripts' named after the release version, e.g.
...
./scripts/1.8.3/script-1.8.3.sql
./scripts/1.8.4/script-1.8.4.sql
./scripts/1.8.4.1/script-1.8.4.1.sql
./scripts/1.8.4.2/script-1.8.4.2.sql
./scripts/1.8.4.3/script-1.8.4.3.sql
./scripts/1.9.0/script-1.9.0.sql
./...
Is there a way to configure MacFUSE to keep a mounted volume alive if the remote host is set to break the connection due to inactivity? If there is no direct way to configure this, would there be a way to write a script to accomplish this?
...