Tuesday, July 17, 2018

#1 2017-12-28 10:40:01 pm

snaplash
Member
Registered: 2014-08-21
Posts: 45

upgraded to Hi Sierra :-(

Hi All!

I upgraded my OS and now I have a problem with "tmpfile" which seemed to work previously...

Heres an example:

Applescript:

do shell script "sed -e 's/%20/_/g' /Users/snaplash/xxx/SNAPLASH_DO_NOT_DELETE/DATA_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & ".txt > tmpfile; mv tmpfile /Users/snaplash/xxx/SNAPLASH_DO_NOT_DELETE/DATA_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & ".txt"

I get an error of mv tmpfile: No such file or directory in the log history. Does this new OS require specific destination to overwrite original file?

Does anyone have any idea what needs to happen? I have been out of the loop for a while and am a bit rusty on applescript

Thank you!


Filed under: tmpfile

Offline

 

#2 2017-12-29 03:57:44 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4599

Re: upgraded to Hi Sierra :-(

I can confirm that there's a permission problem with tmpfile when using your script with a file and folder set up on my own High Sierra machine; but never having used tmpfile before, I don't know if this is something new.

sed itself will edit files in place if you use its -i option with a zero-length extension:

Applescript:

do shell script "sed -e 's/%20/_/g' -i '' /Users/snaplash/xxx/SNAPLASH_DO_NOT_DELETE/DATA_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & ".txt"

But the sed manual recommends not doing this in case of corruption. Instead, use -i with a proper extension. The original file will be preserved with the new extension tagged onto the end of its name and the edited text will be written to a new file with the original name in the same folder. You can then delete the original file if desired:

Applescript:

do shell script "sed -e 's/%20/_/g' -i '.bak' /Users/snapchat/xxx/SNAPLASH_DO_NOT_DELETE/DATA_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & ".txt ; rm /Users/snapchat/xxx/SNAPLASH_DO_NOT_DELETE/DATA_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & ".txt.bak"

It's also a good idea to quote paths and other parameters used in shell scripts. So:

Applescript:

do shell script "sed -e 's/%20/_/g' -i '.bak' " & (quoted form of "/Users/snapchat/xxx/SNAPLASH_DO_NOT_DELETE/DATA_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & ".txt") & " ; rm " & (quoted form of "/Users/snapchat/xxx/SNAPLASH_DO_NOT_DELETE/DATA_DO_NOT_DELETE/" & listingMLSProviderPrefix of theRecord & Mlsid of theRecord & ".txt.bak")


NG

Offline

 

#3 2017-12-31 07:46:38 pm

snaplash
Member
Registered: 2014-08-21
Posts: 45

Re: upgraded to Hi Sierra :-(

Nigel,

Thank you so much for your response! I implemented it with success!

However, like an ungrateful XXXX I forgot to, and didnt respond. :-) I just remembered why my program is running flawlessly and it was because of you!

Happy New Year and Thanks for all of your hard work and dedication!

A little tipsy as its New Years!

Thanks Nigel!

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)