quoted form of
surrounds strings with single quotes and replaces '
with '\''
.
do shell script "d=~/Desktop/LOGS-I-NEED-" & quoted form of (computer name of (system info)) & "
mkdir -p \"$d\"
cp /var/log/system.log \"$d\"" with administrator privileges
You can also get the computer name with systemsetup:
do shell script "d=~/\"Desktop/LOGS-I-NEED-$(systemsetup -getcomputername | sed 's/[^:]*: //')\"
mkdir -p \"$d\"
cp /var/log/system.log \"$d\"" with administrator privileges
If the duplicate command needs root privileges, Finder should show a password dialog. But you could also run a script like this with something like sudo osascript Untitled.scpt
:
set d to "LOGS-I-NEED-" & computer name of (system info) as text
tell application "Finder"
if not (exists folder d of desktop) then
make new folder at desktop with properties {name:d}
end if
duplicate POSIX file "/var/log/system.log" to folder d of desktop
end tell