I have following script to send email when a USB is attached.
Problem with this script is that sometimes it works properly and i can see it using grep command "ps -ef | grep scriptname" but sometimes it doesn't. Unable to understand why it doesn't work sometimes. Please guide.
Hi, just a couple of things that come to mind. Why do you have $( ... )? Does that even work. That should not need to be there (it would only work if there really is no output from those commands inside the command substitution), plus I would replace
with
. The fact that it sometimes does or does not work, may be due to buffering somewhere, so it works but not yet, not in real time. You can test this by having an extra tail -f and check what is written to the log at what point in time..
Why are you using tail and not tail -f? The tail buffer can also be a factor, it can be that the amount written exceeds what tail can display...
Another possibility is that by the time the script starts to do the tail the number of lines has changed and so some lines will never get read...
If you for some reason you need to use tail instead of tail -f, why don't you run the tail buffer straight through grep instead of line for line?
Does your system use udev? Because that would really be ideal for this application.
Last edited by Scrutinizer; 04-15-2012 at 08:40 PM..
It has udev, as revealed in his other threads on the subject. I think he's trying to make it portable, but I'm not sure he realizes non-Linux systems aren't going to have the same log messages anyway.
I continue to agree that using udev for its intended purpose would be the simplest and most reliable way to do this.
My bash below verifies the integrity of all .bam in a directory and writes the out output to a .txt file. That is part one of the script that works. The second part of the bash searches each one of the .txt files for a string "(SUCCESS)" and if found display a message and if it is not found... (6 Replies)
I have a shell script scheduled in cron job to run at every 1 minute which transfers files to remote machine and then move the files to backup folder.
cd /u01/app/ftp_tmp
sftp user@hostname <<-EOF
cd /home/user/ftp
mput *
bye
EOF
mv /u01/app/ftp_tmp/* /u01/app/ftp_bkp
Now the problem is... (6 Replies)
Hi All,
I am calling a shell script from another shell script, however, it only executes part of it (the echo commands only). What could be some causes for that?
For example:
ShellScriptA.sh:
...
...
...
. ShellScriptB.sh
ShellScriptB.sh contents:
echo date
echo... (7 Replies)
I have wrote a script to get a very large encrypted file from a remote ftp server to a local debian box.
The file downloads successfully, but the script never exits, or quits. None of code executes after the ftp get command.
The file is approx 291M
Here is the code:
!/bin/sh... (3 Replies)
Hi,
Batch script gets executed without any error, but on execution some of the partial contents of the batch file gets appended at the end of the file which is currently in execution, hence the script tries to execute again for the second time , which should not happen.
How to get it... (5 Replies)
Below is my script code which filters failed logins from existing and non-existing users from the server. The problem is, it takes longer to execute and complete than expected. Anyone here can edit the script to speed up its execution.
#!/bin/bash
LIST=`cat $1`
for i in $LIST
do... (10 Replies)
Hi,
This script is working successfully when i executed from shell prompt, but the same script scheduled in crontab its not deleting the files,
#! /bin/bash
DAY_1=`(date --date='4 months ago' '+%Y-%m')`
log=/tmp/cleant
adir=/u01/app/oracle/admin/talon/adump... (4 Replies)
Hi All,
Am using the below command to start my application using the root user
su - bin -c "/home/bin/test/start.sh"
but am getting the error becaue i have set some environment varibales in bin's .profile
when i execute the command start.sh by logging directly into bin account it's... (9 Replies)
we have this script that stops, starts and monitor process scheduler. prcs_control. this script runs perfectly when executed by ps_user.
we are now creating a new script that will run this script and is executed by root. this script needs to execute the prcs_control as ps_user because root can... (1 Reply)