I've created a script that runs every night on my Linux server that uses mysqldump to back up each of my MySQL databases to .sql files and packages them together as a compressed .tar file. The next step I want to accomplish is to send that tar file through email to a remote email server for safekeeping. I've been able to send the raw s...
I want to escape a DOS filename so I can use it with sed. I have a DOS batch file something like this:
set FILENAME=%~f1
sed 's/Some Pattern/%FILENAME%/' inputfile
(Note: %~f1 - expands %1 to a Fully qualified path name - C:\utils\MyFile.txt)
I found that the backslashes in %FILENAME% are just escaping the next letter.
How can I do...
In this question someone asked for ways to display disk usage in Linux. I'd like to take this one step further down the cli-path... how about a shell script that takes the output from something like a reasonable answer to the previous question and generates a graph/chart from it (output in a png file or something)? This may be a bit too ...
What's the "right" way to do the following as a boolean expression?
for i in `ls $1/resources`; do
if [ $i != "database.db" ]
then
if [ $i != "tiles" ]
then
if [ $i != "map.pdf" ]
then
if [ $i != "map.png" ]
then
svn export -q $1/resources/$i ../MyProject/Resources/$i
...
...
What command can be used to check if a directory does or does not exist, within a bash shell script?
...
I have to read data from some files and insert the data into different tables in a database. Is Unix shell script powerful enough to do the job?
Is it easy to do the job in shell script or should I go about doing this in Java?
...
In a shellscript, I'd like to set the IP of my box, run a command, then move to the next IP. The IPs are an entire C block.
The question is how do I set the IP of the box without editing a file? What command sets the IP on Slackware?
Thanks
...
Does anyone know of any resources that talk about best practices or design patterns for shell scripts (sh, bash etc...)?
...
I'm looking for the best way to take a simple input:
echo -n "Enter a string here: "
read -e STRING
and clean it up by removing non-alphanumeric characters, lower(case), and replacing spaces with underscores.
Does order matter? Is tr the best / only way to go about this?
...
I have a shell script that executes a number of commands, and if any of the commands exit with a non-zero exit code the shell script should exit.
...
How do I check if a directory contains files?
Something similar to this:
if [ -e /some/dir/* ]; then echo "huzzah"; fi;
but which works if the directory contains one or several files (the above one only works with exactly 0 or 1 files).
...
I know you can use powershell to make things like the registry a drive letter. There are other objects in powershell to treat other objects in this way. Does anyone know of any cmd-lets to access IIS logs in this manner?
...
Can you use the bash "getopts" function twice in the same script?
I have a set of options that would mean different things depending on the value of a specific option. Since I can't guarantee that getopts will evaluate that specific option first, I would like to run getopts one time, using only that specific option, then run it a secon...
I have a file that lists filenames, each on it's own line, and I want to test if each exists in a particular directory. For example, some sample lines of the file might be
mshta.dll
foobar.dll
somethingelse.dll
The directory I'm interested in is X:\Windows\System32\, so I want to see if the following files exist:
X:\Windows\System32\...
I try to write KSH script for processing a file consisting of name-value pairs, several of them on each line.
Format is:
NAME1 VALUE1,NAME2 VALUE2,NAME3 VALUE3, etc
Suppose I write:
read l
IFS=","
set -A nvls $l
echo "$nvls[2]"
This will give me second name-value pair, nice and easy. Now, suppose that the task is extended so that ...
What's a quick-and-dirty way to make sure that only one instance of a shell script is running at a given time?
...
I have already extracted the tag from the source document using grep but, now I cant seem to figure out how to easily extract the properties from the string. Also I want to avoid having to use any programs that would not usually be present on a standard installation.
$tag='<img src="http://imgs.xkcd.com/comics/barrel_cropped_(1).jpg"...
How to stop java process gracefully in Linux and Windows?
When does Runtime.getRuntime().addShutdownHook gets called, and when it does not?
What about finalizers, do they help here?
Can I send some sort of signal to java process from shell?
I am looking for preferably portable solution.
Thanks,
...
How can I determine the name of the bash script file inside the script itself?
Like if my script is in file runme.sh, than how would I make it to display "You are running runme.sh" message without hardcodding that?
Thanks,
...
I have a need to find all of the writable storage devices attached to a given machine, whether or not they are mounted.
The dopey way to do this would be to try every entry in /dev that corresponds to a writable devices (hd* and sd*).
Is there a better solution, or should I stick with this one?
...