Programming :: Write A Bash Script That Continue Monitor The Tmp Directory?
Dec 25, 2010
In my tmp directory some logs are creating continue (with name logs.txt1, logs.txt2 up to 245). Some times these logs are creating continue within 1 or 3 second gap, now I want to write a bash script that continue monitor the tmp directory and if any time logs create simultaneously within 1 or 3 section gap it will alert me..( generally logs are create with the gap of 5 or 10 minutes duration or some time after one hours )
View 1 Replies
ADVERTISEMENT
Apr 5, 2010
I'm trying to write a bash script that gets the list of files in a directory and puts them into a variable, then checks each entry and outputs them as follows:
item1 is a FILE
item2 is a DIR
item3 is a DIR
etc etc.
I am able to get the list of files into a variable, but unsure how to get the output I want.
View 3 Replies
View Related
Sep 1, 2011
I'm trying to write a bash script which will find files then move them to a specific directory.
So far I have:
Code:
#!/bin/bash
#script to find and move files
src_dir="/path/to/source/directory"
des_dir_mov="/path/to/destination/directory/for/movies"
des_dir_img="/path/to/destination/directory/for/images"
find $src_dir -iname '*.avi' -type f -exec mv '{}' $des_dir_mov ';'
I'd like to have all the possible movie file types then the image file types checked in a loop.
Every time I try to include an array in this script it breaks
View 3 Replies
View Related
Nov 29, 2010
i have a text file like
abc abc abc abc
abc abc abc abc
--- --- --- ---
i want to add a string xyz to end of each line..
abc abc abc abc xyz
abc abc abc abc xyz
abc abc abc abc xyz
--- --- --- --- xyz
--- --- --- --- xyz
how do i do this in bash?
View 13 Replies
View Related
Jun 3, 2010
I have been looking for a script example of reading and writing to the parallel port's data, status, and control registers using bash. I see it done in pascal, tcl, etc. but nothing in bash.
View 5 Replies
View Related
Jan 15, 2010
There are a few PCs on the network that lose network connection every so often -- sometimes these old beasts have a power failure and owing to a bug in the BIOS the NIC doesn't necessarily initialize properly, which requires a reboot to correct it. Got me thinking of a band-aid -- have the PC ping a specific IP address, and if it cannot ping then it forces itself to reboot.
IF I were to write it in BASH I'd do it like this:
#!/bin/bash
HOST=<some meaningful hostname or IP address>
for ipaddy in $HOST
do
count=$(ping -c 1 $HOST | grep 'received' | awk '{print $4}')
if [ "$count" = "0" ]; then
sh usr/bin/reboot
fi
done
In English: send 1 ping to the IP address. Grep through the results to see how many of 1 ping was returned. IF it returns 0 pings then reboot. I'm sure the reboot command would have to be groomed a bit for sudoers but that's beside the point here.
So, HOW do we write something like this for DOS? Stop giggling (lol). No really, I have Windows 2000 & XP machines that need some sort of script or method of knowing (at intervals) of when they're not talking to the Host system, and need to reboot to fix it. I was thinking to write a simple test script, drop it on each of these machines and use the Windows task scheduler to run it every 30 minutes.
View 3 Replies
View Related
May 24, 2010
I am trying to write a bash script to call from a terminal that will change the terminal title. I am using ubuntu 10.04. The script is meant to be used in the gnome-terminal.
Here is what I have:
Code: #! bin/bash
echo "New title: c"
read title
echo "33]0;$titl07c" -e
[Code]....
it doesn't work
I think the problem has to do with modifying PS1 inside the bash so i tried this:
Code: echo `export PS1="[e]1;u@h:wa]${debian_chroot:+($debian_chroot)}u@h:w$ "` and it still didn't work.
View 1 Replies
View Related
May 15, 2011
I want to write a bash script that will launch a command when ever I plug my phone in. how would I monitor the port in a script.
View 2 Replies
View Related
Feb 15, 2011
At the moment I got my md5sum checking working which I write to a text file and see below.
If the md5sum works it will write the output to check2.md5 test.txt: OK
If the md5sum fails it will write test.txt: FAILED
How do I write if statement to check the output whether or not the md5sum failed or not ?
check1="/home/ops/Desktop/test1/check1.md5"
check2="/home/ops/Desktop/test1/check2.md5"
cd /home/ops/Desktop/test1
md5sum test.txt > $check1
[Code]....
View 2 Replies
View Related
Jan 20, 2011
I have a bash script that checks for contents in a folder every 15 seconds and then acts on it's contents. This works great for the average size file however on very large files it starts acting on the file before it's completely written. Is there a facility in bash shell to get a file complete signal or such? here is trigger to launch a larger script.
Code:
#!/bin/sh
while true
do
$HOME/bin/hpgl.sh >/dev/null 2>&1 &
[code].....
View 10 Replies
View Related
Jun 23, 2010
I'm planing to write a bash script that will make some web stats reports and I'm stuck on beginning because I don't know how can I read a directory content, put everything in a variable, compare the variable value with current date and go further.More specific ...
I have /var/apache/log/. Here I have access logs on date ( like access.log.24.06.2010.gz and so on ).
How can I do to automatically zgrep (in a bash script) last day .gz ??
View 3 Replies
View Related
Oct 6, 2010
I try to write a bash script that recognizes when the mouse moves.
like a screensaver.
But I want that while a browser window is opened and I move the mouse that a new webpage loads.
I can open opera with a console command but how can i recognize that the mouse moved?
View 1 Replies
View Related
Jan 31, 2011
I have a folder of 2 many files that the old ls just hangs.
I am trying to write some log files such as;
I don't mind doing one at a time, but I am just playing and even getting the listing I am not getting the date stamp, I have the following;
That does create the file, but all the files look like this;
So basically it's just sticking that ls inside the log file and not actually running the ls, so how can I use the above type to get files just created per year?
View 2 Replies
View Related
Jan 29, 2011
I am trying to write a bash script that sources another bash script. Essentially, I need a few lines to check to see if a certain variable is set. If not, I set it manually, and then source a scripts with that variable in the path. I wrote a test script to try it, but for some reason the last line does not work. Here is what I wrote:
#!/bin/sh
source ~setupdir/setup.shrc #just a test, this line works
echo ${#SETUP} # prints 0 if setup is not set, which it isn't
if [ ${#SETUP} -eq 0 ]
then
SETUP="~setupdir"
fi
echo $SETUP # prints ~setupdir
[Code]...
View 5 Replies
View Related
Nov 19, 2008
How can I write a script that will go through the files in a directory and print on the screen the name of the files stating if it is a file or directory. The directory is already provided by the user.
View 12 Replies
View Related
Jun 8, 2010
I write a bash script to time some downloads from a server using ftp connection. ( something like: "time ftp 'options' ) I need to count the time for a list of files in a loop and output the result in a file.
View 1 Replies
View Related
Mar 22, 2010
I'm trying to write a bash script program in the Linux command terminal that will write to a fellow user and then continue reading down the program. this is what i have (kind of explains the idea too):
#!/bin/sh
clear
echo "this is before the write command"
write jcummins
this message should go to jerry
echo "the message didn't send and this string will not appear"
echo "it appears it has stopped at the write command"
View 5 Replies
View Related
Oct 13, 2010
This code uses ping to check connectivity to a remote location and logs it to a .html file which is then stylized by css..
Code:
#! /bin/bash
path="$HOME/Desktop/IP_Monitor" #Path to write out files
ALT="0" #For styling alternative row
[code]....
I need to add a feature such that instead of hardcoding the ip address .. it takes them from a list and makes new files for each ip address for logging.. And also when log files are completed , They should be compressed using tar. How should i go about adding both these.. This is my first bash script.
View 6 Replies
View Related
Jan 20, 2009
I'm trying to write a script that will calculate a directory size and if the size is greater than 4GB, it will send out an email. But I am getting the "integer operation expected" error when it tries to calculate the current disk size. Here's my script.
Code:
TO="user@email.com"
SUBJ="Ready for DVD burning on `hostname`"
MAIL="/bin/mail"
[code]....
View 1 Replies
View Related
Aug 19, 2010
I have a bunch of files that contain a date, then data. When I use join, I get exactly the output I need. But manually joining the first with the second, then that output with the third and so on would take days. I have thousands of files. Can any of you folks help me write a script that would do this?To put it another way, for clarity's sake, here is what I am currently doing
If I were to repeat that 3000 times the final output would be what I need. I know a simple script would do this for me, but I can't figure out how to write it.
View 12 Replies
View Related
Apr 1, 2011
I want to write a script that will detect all the unwanted files in a particular directory and delete them in one fly..
View 11 Replies
View Related
Apr 20, 2011
Over the past two weeks my laptop has started locking up at random. I thought maybe it was a thermal issue, because I have an upgraded hard drive (put in 2 years ago) and once a month or so I might get a heat related lockup. I keep my fans running at high speed and the laptop elevated now and don't typically have an issue.
The freezing has started to become a daily occurrence now, and yesterday it locked up three times. I am able to move my mouse (unlike thermal lockups where everything goes down) but unable to click anything. The entire display freezes, and my cpu monitor doesn't continue to update.
I finally ssh'd into my laptop and was surprised to see it responding just fine. htop showed that my X-server was at 100%. When I killed it, X restarted automatically and promped me to log in. Everything is fine after this until the next lockup.
When I don't have access to ssh I have to hard-shutoff the laptop. That can't be good on this 5 year old macbook. I have done my system updates in the past two weeks that may have triggered this, but I don't remember anything specifically. I've tried all versions of my kernel that are installed but nothing, I have the intel video and have not had problems with it up until now.
2$ uname -a
Linux macbook 2.6.32-30-generic #59-Ubuntu SMP Tue Mar 1 21:30:46 UTC 2011 x86_64 GNU/Linux
3$ lspci|grep VGA
00:02.0 VGA compatible controller: Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller (rev 03)
Can anyone suggest something to try? I'm not sure how to go back to older versions of the the video drivers, but I'm not even sure if that is the issue. I did add the following to /etc/apt/sources.lst after the lockups started occuring:
Code:
# X
deb http://ppa.launchpad.net/ubuntu-x-swat/x-updates/ubuntu lucid main #X-Updates PPA
deb-src http://ppa.launchpad.net/ubuntu-x-swat/x-updates/ubuntu lucid main #X-Updates PPA
and did a full update, but this hasn't helped.
I'm running Ubuntu 10.04 LTS
View 5 Replies
View Related
May 23, 2011
I have a (rather large) database of mp3 track information. I also have several directories of the actual mp3s. I'm trying to write a simple bash script that will check the contents of the directories against what's in the database, and upon finding a file that isn't in the database, do something.
Here's what I have so far:
Code:
The trouble I'm having (in the sample directory of "/mnt/music/B/Beatles, The/" the file "Beatles, The - Taxman.mp3" isn't in the database.) is getting it to actually trigger an error when an entry isn't in the database.
Once triggering on a non-entered file is working, any way to get it to traverse the entire /mnt/music hierarchy?
View 13 Replies
View Related
Jun 30, 2011
I've got the following code and kludge. It's working okay except that there's a directory called "Archive" which I don't need to backup. I've tried various combinations of &&, -a, etc., and I'm kind of at a loss for getting this right.
Here's the code I have so far:
Code:
#!/bin/sh
# backup subdirs as individual tarballs with prepended timestamps and
# move them somewhere else.
# --exclude "/path/to/dir/*" (Doesn't seem to work)
[Code]...
How can I write that line so that I can loop through all of the subdirs, tarring them up, but excluding the "Archive" subdirectory?
View 6 Replies
View Related
Apr 11, 2009
I am programming in bash and really stuck finding directory names. I have a script to find all the .php files on my / partition which will return the whole path. Is there a way to print directory hierarchy with all those values leaving out the forward slashes.
View 10 Replies
View Related
Nov 6, 2010
I am trying to write a simple script to list all the files in a directory. The script I wrote was as below where the pdb_files is a directory and all the files which I want to list are in that folder.
Code:
files=`ls -F pdb_files/*THERMO*`
for inFiles in $files
do
echo $inFiles
[Code]....
View 5 Replies
View Related
Jul 22, 2011
I have about 50 files that the script will operate on, they are all located in the same directory.I need a bash script that will operate on all files in a directory. The script needs to add two lines to the beginning of each file based on the file name, and one line to the end of the file.A file named myfile.h should add these two lines to beginning of the file:
Code:
#ifndef MYFILE_H
#define MYFILE_H
[code]....
View 5 Replies
View Related
Jan 31, 2009
i was wondering if there's a bash script to check the amount of files in a directory with an IF statement..
View 8 Replies
View Related
Jul 22, 2010
I have a Directory of files over time the directory has become a pain to manage... Its now a few 100GBs each file has a partner .log file so id would want some logic in keeping these together..So I want a script to move the files into sub-directories with a limit or 4GB and then i'll burn each of the directories to DVD.
View 14 Replies
View Related
Mar 12, 2010
I have a directory and sub-directories (4 or 5 depths). There are several type with extension in them (*.mp3, *.wma, *.jpg, etc). I would like to copy the whole directory to another location recursively but only *.mp3 files.
View 11 Replies
View Related