The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
logout script common for both Mac and Linux? harsha10 UNIX for Advanced & Expert Users 0 06-27-2008 03:17 PM
run a script at logout harsha10 UNIX for Dummies Questions & Answers 0 06-22-2008 09:01 AM
set schedule to run a script at background while logout happyv Shell Programming and Scripting 1 01-24-2007 01:17 AM
Login and logout script jhansrod UNIX for Dummies Questions & Answers 1 06-06-2005 07:54 AM
logout/shutdown script ropers UNIX for Dummies Questions & Answers 1 08-02-2002 03:05 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 4 Weeks Ago
AGGreenLinux AGGreenLinux is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 5
Logout script - delete a file

Good evening you scripting guru's!

I have the following script to delete a file on logout of a Mac :
Code:
find  . –name com.apple.sidebarlists.plist –exec  rm  -f {} \;
It works fine in terminal and when logging out. However, it takes forever to run the script at logout...A minute and a half.

Is there a way to just run the command and targeting the current directory it is contained in? What would the syntax be to search the directory Library/Preferences?

Thanks,
AG

Last edited by pludi; 4 Weeks Ago at 12:47 PM.. Reason: code tags, please...
  #2 (permalink)  
Old 4 Weeks Ago
Scrutinizer Scrutinizer is online now
Registered User
  
 

Join Date: Nov 2008
Posts: 705
perhaps you could try:
Code:
nohup find . -name "com.apple.sidebarlists.plist" –exec rm -f {} \; &
  #3 (permalink)  
Old 4 Weeks Ago
dr.house dr.house is offline
Registered User
  
 

Join Date: Dec 2008
Location: Switzerland
Posts: 229
Quote:
Originally Posted by AGGreenLinux View Post
Is there a way to just run the command and targeting the current directory it is contained in?
If you already know the file's name and location, why don't you just remove it
  #4 (permalink)  
Old 4 Weeks Ago
AGGreenLinux AGGreenLinux is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 5
delete file

Deleting is the easy part....
History of this:
We run an AD environment with MACs running 10.3.9 and 10.4.11

The com.apple.sidebarlists.plist sets up differently when logging onto either OS. So, when you go back and forth between OS's - A volume error occurs. Apple has confirmed this issue.

Their suggestion was to write a script to delete the file at logout.

The script above actually works, but thier is a lag time when logging out.

I tried the nohup command, but so far it hasn't worked for a user connected to the server.

Using the (find . -name) searches through all files on the drive before hitting the correct file to delete. (SLOW)

I have tried find ./Library in the sh but it only works in terminal and will not work when logging out.

Is there a variable in which I can put into the script that will go directly to the file and delete it?

Thanks for any suggestions.

AG
  #5 (permalink)  
Old 4 Weeks Ago
thegeek thegeek is offline
Registered User
  
 

Join Date: Apr 2009
Location: /usr/bin/vim
Posts: 453
You need to give absolute path in the find command, like

Code:
find /var/lib -name 'NAME'
It seems like, it takes time for searching in many places to delete, so you can use absolute path, and let us know.

Also, there is a useful option -xdev in "find", which will be of great use to you if you have multiple filesystems and wasting time in other places.
  #6 (permalink)  
Old 4 Weeks Ago
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,183
What is the absolute pathname of: Library/Preferences ?
  #7 (permalink)  
Old 4 Weeks Ago
trey85stang trey85stang is offline
Registered User
  
 

Join Date: May 2008
Posts: 70
Is the file stored in different locations between the osx versions?

sw_vers -productVersion will give you the major minor and patch level.

OSXVER=`sw_vers -productVersion | awk -F. '{print $1 "." $2}'`

I use the above variable to run different script stuff against different osx versions. Since they all seem to be different and require specific scripts for each one
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:02 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0