![]() |
managing cookies with applescript
hello there,
i made a poorman's cookiecutter with applescript. what it does is replace the cookies.plist inside the prefrences folder with a backup i keep in the documents folder. of course the backup contains the cookies i wanna keep. the script: tell application "Finder" duplicate "bigwig:Users:alibaba:Documents:Cookies.plist" to "bigwig:Users:alibaba:Library:Cookies" with replacing end tell the problem: i have set this applescript as login item and that works fine but sometimes i don't reboot for a long time and i then i want to run it intermittently.. the problem is that sometimes it won't run and the script will give me an error message saying "operation could not be completed ". it doesn't matter whether safari is running or not. restarting the finder always solves this issue but i don't like that extra step.. i'd like to understand why it won't run sometimes and how to fix it. .. also if someone has a alternative way for this poorman's solution i'd like hear that too of course. tia, ali baba |
hey now
that smilee after alibaba was not intended! it's a colon plus captial d that turned into smilee. i am not the kind of guy to do such a thing. please forgive me if someone is insulted!!
|
you can [x] disable smilies in your posts. examine options frame on a 'post' page.
|
Re: managing cookies with applescript
Quote:
Code:
tell application "Finder" |
Re: Re: managing cookies with applescript
hi rob,
alas same results for both scripts, they both work or they both don't at given a situation and if i use: tell application "Finder" duplicate "bigwig:Users:alibabaocuments:Cookies.plist" end tell then i get the same error in case it doesn't work. so i get the impression that the "with replace" is not the issue (yet). duplicating itself causes an error to begin with.. as if the finder thinks that file is already in use |
I wonder if it would help to delete the file first.
Code:
tell application "Finder"-- Rob |
Quote:
[/QUOTE] Regarding the file in use, I wonder if a command from the shell would have the same issue. [/QUOTE] woooooooo shell, please tell me more, i'm still a rookie with that |
Quote:
|
Quote:
-- Rob |
Quote:
Quote:
i'll sit here and wait until a kindred soul comes along who knows shell then |
man i don't even know what kindred is, i thought it meant friendly
|
According to Spell Catcher:
Quote:
Code:
do shell script "rm -f " & (quoted form of (POSIX path of "bigwig:Users:alibaba:Library:Cookies:Cookies.plist"))If you decide to test it, make sure you do it on a copy because this does not simply move the file to the trash - it deletes it. -- Rob (who is more comfortable with pure AppleScript) ;) |
Quote:
Quote:
|
Instead of beating Applescript over the head to do a shell job, just use the shell directly.
Save the following somewhere meaningful, like ~/Library/Scripts/cookiemanager.sh Code:
#!/bin/shuse Cronnix to create a line like the following: Code:
15 */6 * * * /bigwig/Users/alibaba/Library/Scripts/cookiemanager.sh |
hi acme.mail.order, thanks for responding, i understood the cronnix part but have some questions
Quote:
i really have no idea Quote:
|
Quote:
|
ali baba, no offense taken. :)
-- Rob |
Shell scripts must be plain, plain text. Textedit can do it, but its better if you use the Terminal editors.
Open Terminal (Applictions -> Utilities) and type the following: Code:
cd Library/ScriptsHmmmmmmm - I think you should remove /bigwig from the above script, unless you have done funny things to your system paths. bigwig is the name of your one and only drive? Yes? Then remove it from the shell and Cronnix scripts. And do a Google search for an introduction to unix. |
thanks a bunch it's working
you were right about the paths, it only works when i leave off my volume-name. that goes for the path inside the cookiemanager.sh as well as in the crontab itself. but i do have other drives.. can this become an issue? is there a way to invoke/run the script quickly from the terminal so i can run it intermittently? typing the cp command with the paths is so hassle-some. if you care could you explain what "chmod +x cookiemanager.sh" does. i did notice it doesn't work without it but i thought chmod was a permissions command and when i look at the permissions via the get-info window it's setting are the same before and after that command. Quote:
|
chmod is permissions, but permissions include eXecute - the file is program code rather than a recepie for borscht. Unix only runs files with the 'x' bit set, the Mac finder doesn't care (at least not at this level)
to run the program, first try the Apple way - double click on it. Doesn't work on 10.2 unless you change the .sh to .command Unix and the script don't care in the slightest what the filename is. to run the script from the command line, `cd` to the directory and then type ./scriptname or type the path to the script and it will run. You will find your other drives in the Terminal in the /Volumes folder, but don't mess around with the /Volumes folder content until you understand unix mount points. Do not attempt to backup, restore, delete, copy, fold, spindle or otherwise mutilate this folder. as far as your scripts are concerned, replace `bigwig` with `/` and you will be on the right track. Other drives can be reached by `/Volumes/Drive\ name\ with\ spaces/folder1/folder\ 2/file` |
Quote:
Quote:
Quote:
"cp //Users/me/Documents/Cookies.plist //Users/me/Library/Cookies/Cookies.plist" double slash before "Users"? |
no, single slash.
cp /Users/me/Documents/Cookies.plist as for running the script, did you set permissions properly? to check, cd to the same directory and type `ls -l` (lower case 'L', not number one) example output: Code:
-rwxr-xr-x 1 admin wheel 78 7 Jan 00:17 sendipCopy the results of `ls -l` of the folder containing your script and we'll see what's wrong. |
hi acme.mail.order,
the changing .sh into .command works fine! i didn't get that yesterday due to excessive juggling around with files and then mixing up. the permissions of the script were set as in your serendip example. when i asked you for a terminal way to trigger the script i had forgotten about rob's hint to use a do shell applescript. for the smoothest user experience i'll go with that for now but it's fun to know the geeky way too. i feel like coyote who gets his acme mail order, anxiously upwraps the package, folds out the blueprint, succeeds in building it.. and then.. on to his next disaster, but that's another story. thanks for teaching me some extra unix :) later, ali baba |
Quote:
|
:)
repairing parachutes, shellscripts, cron, coyote, acme mail orders, pico, cookies, kindred smilees on the loose.. it's been a fun thread! later, ali baba |
| All times are GMT -5. The time now is 06:08 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.