Hi
Im new to BASH scripting, I have created a simple script
this creates a log file with the date as part of the name, how
can i place output of the script into this file ?
for example i need to have a simple mail script which i have done seperately
I need to be able to output to the log file if mail was successfully sent,
or an echo message if i add one ?
You can leave out the touch command if you wish, just add either > $LOGFILE or >> $LOGFILE to the end of any command you want to record STDOUT from. ( in sh, 2> grabs STDERR)
>> creates the file if it doesn't exist and appends to it if it does
> creates the file if it doesn't exist and overwrites it if it does
Note that the shell expression "${0##*/}" is the same as "basename $0". Also, the "[[ -t ]]" should return TRUE when the process is attached to a terminal. In this case, it just prints a message about the logfile (instead of having the user wonder if the script is even running).
I also close stdin since an unattended script should never need input. For instance, if you have "grep $FILENAME" or "cat $FILENAME" and a bug has left $FILENAME unset, then the script would normally hang waiting for input from stdin. If that input is already /dev/null then the script can continue.
Once you have run "exec" to redirect the output, you can't send messages to the terminal anymore unless you use "echo > /dev/tty".
I don't think this is exactly what you were looking for but I think you'll find it helpful.
I am on linux red hat, want to use the logic within bash shell script file.
I have the following type, named files in folder /staging, want to move with new filename just the firstpart upto underscore, example 20180904105056.dat, how can i get upto first part of filename and validate to chk if... (2 Replies)
Hi Guys,
I want to combine 2 files and and put together in 1 file . See below desired output. Any help will be much appreciated.
FILE AX 2134 101L 12345.00 22222.00 1 10
X 2134 101L 12345.00 22222.00 11 20
X 2134 101L 12345.00 22222.00 21 30
X 2134 111L 77777.00 ... (3 Replies)
Our Apache log files are written to a location on the server that we as clients have no access. Don't ask.
Every month, I have to e-mail the administrator to have him manually copy our Apache log files to a directory in our file space. You can probably guess how efficient it is to do things this... (3 Replies)
hello.
How can I detect within script, that the downloaded file had not a correct size.
linux:~ # wget --limit-rate=20k --ignore-length -O /Software_Downloaded/MULTIMEDIA_ADDON/skype-4.1.0.20-suse.i586.rpm ... (6 Replies)
have this code but when i run it i get this error
./pulse: line 2: and here is the code
#!/bin/bash
if ;
then
pulseaudio -k;
fi
what am i doing wrong
thanks
Adam (5 Replies)
I currently have a script that was written a while back and it generates it's own log file. I had to recently alter this script so that it would execute another script in parallel 10 times such as the following example;
echo "It is currently: ";date
int=0;
cap=10;
while((int <... (2 Replies)
I want to compare "N" (around 2000+) number of huge files located in a directory A against "N" files located in a different directory using Bash scripting.
Please help me with any scripts available.
Thanks. (2 Replies)
Hi,
I'm quite new to scripting and need some help. I need to have one script that will check specific directories for files older than one month and then have the script delete them.
I have written the script below but it only does one directory. I don't quite know how to make it so it... (7 Replies)