• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Inconsistent results with "do shell script"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inconsistent results with "do shell script"


  • Subject: Re: Inconsistent results with "do shell script"
  • From: "koenig.yvan" <email@hidden>
  • Date: Tue, 15 Jul 2014 15:21:14 +0200


Le 15/07/2014 à 10:38, Axel Luttgens <email@hidden> a écrit :


Le 15 juil. 2014 à 09:20, Lists a écrit :

[...]

set targFile to choose file
set QPP to quoted form of POSIX path of targFile
set targFolder to "~/Desktop/"
set shellScpt to "ln -s " & QPP & " " & targFolder
do shell script shellScpt

[...]

tell application "AppleScript Editor"
choose file
--> alias "Sox:Users:j:Applications:Apps-Games:Adapter.app:"
end tell
tell current application
do shell script "ln -s '/Users/j/Applications/Apps-Games/Adapter.app/' ~/Desktop/"
--> error "ln: /Users/j/Desktop//: File exists" number 1
Result:
error "ln: /Users/j/Desktop//: File exists" number 1
The link was not created

Any thoughts on how to make it work every time?

Hello,

Looks like command "ln" parses a bit too lazily its source argument.
This should be circumvented by removing a trailing slash, if any, from the value of your variable QPP.

HTH,
Axel


One more time, I received ans answer whose original question never reached my mailbox.

Here is the script which I use for months to create symlinks.
I assumes that if I don't use ln -s it's because I never found a way to get it to work correctly.
Here, running OS X 10.9.4,  I get the same error message :
--> error "ln: /Users/<home>/Desktop//: File exists" number 1

#[SCRIPT crée lien symbolique]
(*
# +-+-+-+-+-+
Exécuter ce script ou déposer l'icône d'un fichier
sur son icône (script enregistré en tant qu'application)
crée sur le bureau un lien symbolique vers le fichier.

Save the script as Application on the Desktop.
Drag and drop a file's icon on the script's icon
will create on the Desktop a symlink to the file.

Yvan KOENIG (VALLAURIS, France)
5 janvier 2014

# +-+-+-+-+-+
*)


#=====

# lignes exécutées si on double clique l'icône du script
on run
if my parle_anglais() then
"Choose a file …"
else
"Choisir un fichier …"
end if
set _ to choose file with prompt result
my TraiteLeFichier(_)
end run

#=====

on open sel # sel contient une liste d'alias des éléments 
# qu'on a déposés sur l'icône du script (la sélection)
my TraiteLeFichier(item 1 in sel)
end open # fin 2

#=====

on TraiteLeFichier(zefile)
try
set leChemin to zefile as text
tell application "ASObjC Runner" # Thanks to Shane STANLEY
manage file leChemin creating symlink in (path to desktop)
end tell
on error MsgErr number NroErr
if NroErr is not -128 then
beep 2
if my parle_anglais() then
"Oops"
else
" Vu "
end if
tell application "SystemUIServer" to ¬
display dialog "" & NroErr & " : " & MsgErr with icon 0 ¬
buttons {result} giving up after 20
end if
return
end try
end TraiteLeFichier

#=====

on parle_anglais()
return (do shell script "defaults read 'Apple Global Domain' AppleLocale") does not start with "fr_"
end parle_anglais

#=====

#[/SCRIPT]

Yvan KOENIG (VALLAURIS, France) mardi 15 juillet 2014 15:20:33



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Inconsistent results with "do shell script"
      • From: Shane Stanley <email@hidden>
References: 
 >Inconsistent results with "do shell script" (From: Lists <email@hidden>)
 >Re: Inconsistent results with "do shell script" (From: Axel Luttgens <email@hidden>)

  • Prev by Date: Re: Inconsistent results with "do shell script"
  • Next by Date: Re: Inconsistent results with "do shell script"
  • Previous by thread: Re: Inconsistent results with "do shell script"
  • Next by thread: Re: Inconsistent results with "do shell script"
  • Index(es):
    • Date
    • Thread