UNIX cache problem?

 
Thread Tools Search this Thread
Operating Systems OS X (Apple) UNIX cache problem?
# 1  
Old 12-27-2012
UNIX cache problem?

So I worked out a script for Mac OSX from an existing script. This script checks the versionnumber of a plugin and a package. If the plugin version is different from the package it has to update the plugin. The script works fine but the final check fails.

Here is my script:

Code:
#compare version numbers
installedversion=`/usr/bin/defaults read /location/plugin.plugin/Contents/Info CFBundleShortVersionString`
newestversion=`/usr/bin/defaults read /otherlocation/plugin.pkg/Contents/Info CFBundleShortVersionString`
if [ "${installedversion}" != "${newestversion}" ]; then
installer -pkg /otherlocation/plugin.pkg -target /
# check if the installation succeeded
newlyinstalledversion=`/usr/bin/defaults read /location/plugin.plugin/Contents/Info CFBundleShortVersionString`
    if [ "${newestversion}" = "${newlyinstalledversion}" ]; then
        /bin/echo "`date`: SUCCESS: ${newlyinstalledversion} installed..." >> ${logfile}
        else
        /bin/echo "`date`: ERROR: update unsuccessful, version remains at {installedversion}." >> ${logfile}
    fi
fi

So lets say the installedversion is OLD and the newestversion is NEW.
It keeps saying ERROR. If I manually check the version number it's updated to version NEW.
If I add a line to the script to echo the ${newlyinstalledversion} to the log file it says OLD.
I tried to add 10 or 20 seconds 'sleep' after the installer command but that didn't help.
Is this a cache problem?

Last edited by mattiasvdm; 12-27-2012 at 06:37 AM.. Reason: added OS
# 2  
Old 12-27-2012
Is this OS X?
# 3  
Old 12-27-2012
Quote:
Originally Posted by Scrutinizer
Is this OS X?
Sorry, forgot to mention. Yes, it's for Mac OS X 10.8.

Last edited by mattiasvdm; 01-02-2013 at 04:36 AM..
# 4  
Old 12-28-2012
In older versions of OS X the filesystem would sync every 30 seconds by a daemon called updated. It's gone in the latter versions with the advent of launchd. My guess is FSEvents is now involved.
# 5  
Old 01-02-2013
Well I'm pretty new to unix scripting so FSEvents doesn't directly ring a bell. I've searched it and I think I understand what is does. But I don't really see the connection to my problem.
Is it maybe because I define two variables with the same path?
Code:
     installedversion=`/usr/bin/defaults read /location/plugin.plugin/Contents/Info CFBundleShortVersionString`
newlyinstalledversion=`/usr/bin/defaults read /location/plugin.plugin/Contents/Info CFBundleShortVersionString`

# 6  
Old 01-02-2013
Set your script in debug mode by adding set -x on the next line after the shebang. This will display the value of your variables.
# 7  
Old 01-03-2013
Quote:
Originally Posted by xbin
Set your script in debug mode by adding set -x on the next line after the shebang. This will display the value of your variables.
Thanks, that comes in handy! But the results only show what I already knew. But I got a little further. I thought maybe it just needs more time. So I put 40 seconds after the installer command and now it did say version NEW. Then I changed it to 20 seconds and again version NEW. But when I changed it to 10 seconds it said version OLD.
The strange thing is that when I look at the actual .plugin in Finder during the installation, the version almost directly changes to NEW. After that the sleep command runs for 10 seconds. After the ten seconds it still reads out version OLD.

So somehow it does cache the information somewhere...

---------- Post updated 03-01-13 at 11:02 AM ---------- Previous update was 02-01-13 at 02:34 PM ----------

Oke,

So I found another workaround, not a real solution. The plugin has besides an Info.plist also a Version.plist. So I've done some testing.

If I use the CFBundleShortVersionString from the Version.plist for the installedversion as well as the newlyinstalledversion I get the same problem. But If I use the Version.plist for the installedversion and the Info.plist for the newlyinstalledversion then it works properly. Even without the 10 seconds sleep.

Since this script can be used for more software other than this plugin this is not a real solution. Because not all plugins or apps have the version.plist.

I also tried unset installedversion but that didn't help either...

---------- Post updated at 11:54 AM ---------- Previous update was at 11:02 AM ----------

I also found something in another post that maybe will help finding a solution:

Quote:
When you run a script or program, it gets a copy of your current environment. But the copy is unconnected. Change the child and the parent remains the same, and vice versa.

Last edited by mattiasvdm; 01-03-2013 at 06:51 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

DNS Cache Problem-Urgent !!!!!!

I have DNS Server running in solaris 10 . There is website called exaple.com ,whcih was hosted in this dns server with IP 1.2.3.4 ,now we deleted the DNS entry of that website from our DNS Server (db.exmaple.com is deleted from named.conf ) and it is hosted with some other name server with IP... (1 Reply)
Discussion started by: sandeep.tk
1 Replies

2. Linux

File cache /Page cache Linux

Hi All, could any one point out any open source test-suites for "File cache" testing and as well as performance test suites for the same. Currently my system is up with Linux/ext4. Regards Manish (0 Replies)
Discussion started by: hmanish
0 Replies

3. HP-UX

Performance problem - waiting on cache

My server is running HP-UX 11.23 and one Oracle database. The server has 8 CPUs and is mostly idle all the time. Buffer cache is set to 10%min/max with 5GB memory on the server. I have a user complaining that a batch process is all of a sudden taking a long time to finish. The DBA gave me the... (13 Replies)
Discussion started by: keelba
13 Replies

4. Linux

getting info on Cache Size, Data Cache etc..

Hi all I saw in Microsoft web site www.SysInternals.com a tool called CoreInfo from able to print out on screen the size of the Data and Instruction caches of your processor, the Locigal to Physical Processor mapping, the number of the CPU sockets. etc.. Do you know if in Linux is available a... (2 Replies)
Discussion started by: manustone
2 Replies

5. Linux

Linux cache

Hi all I am trying to understand the kernel memory management and require assistance in this regard. Kernel first creates the cache memory to perform any subsequent allocation to processes. I could not figure out how it is accomplished. Do kernel directly allocates any hardware cache or allocates... (0 Replies)
Discussion started by: joshighanshyam
0 Replies

6. IP Networking

how can we spoof ethernet by ARP cache poisoning on unix through a program

how can we spoof ethernet by ARP cache poisoning on unix through a program... can anyone post the source code to achieve this... (1 Reply)
Discussion started by: ud4u
1 Replies

7. Filesystems, Disks and Memory

Unix Sco Open Server, Windows Computers Problem Access Unix Shared Files Help!!!!!

Hello Moto I hope someone can help We's here at work, have a unix box with sco openserver 5 on it, so it has a nice gui interface.. and also a fair few windows computers.. a system admin guy b4 me, has set up a user called neil, which can, when u try to access the unix box using windows... (2 Replies)
Discussion started by: haggo
2 Replies

8. Solaris

Unix Cache / Buffer

Does anyone know how the unix buffer / cache is set in a Solaris based system ? ( I presume it is a kernel based setting ) I notice from SAR -d that my read cache is consistently at 100% but my write cache frequently falls below 65%. What does this mean. Should I be tuning the write cache and... (1 Reply)
Discussion started by: jimthompson
1 Replies

9. UNIX for Advanced & Expert Users

UBC cache vs. Metadata cache

hi, What is the difference between UBC cache and Metadata cache ? where can i find UBC cache Hits and Metadata cache Hits in hp-ux? Advanced thanx for the help. (2 Replies)
Discussion started by: sushaga
2 Replies

10. UNIX for Dummies Questions & Answers

UNIX problem? Unix programm runs windows 2000 CPU over 100%

Okee problems...!! What is happening: Unix server with some programms, workstations are windows 2000, the workstations work good but when you start a programm on the Unix server the CPU of the workstations go to 100% usage resulting that the system gets very slow. The programm well its running so... (2 Replies)
Discussion started by: zerocool
2 Replies
Login or Register to Ask a Question