How to save the sudo password in AppleScript? I need to use tell Terminal ... to do ... sudo ping ... and I need it to repeat in many windows. It asks for the sudo password every time. Is there any way I can ask the user for the password and then make AppleScript enter it every time the sudo password is required?

A correctly-formed ping packet is typically 56 Bytes in size. I need to send larger ping packets (65507 Bytes) which is only allowed as root.
Instead of temporarily storing your password in an application/AppleScript it might be easier to enable password-less sudo access to ping:


Run sudo visudo to open the sudoers file
Add a line %admin ALL=(ALL) NOPASSWD: /sbin/ping to give all users in the admin group password-less access to sudo ping


Afterwards you can just use sudo ping from Terminal or Applescript.

$ sudo ping -s 65000 askdifferent.com
PING askdifferent.com (104.27.182.101): 65000 data bytes
65008 bytes from 104.27.182.101: icmp_seq=0 ttl=56 time=1250.724 ms
65008 bytes from 104.27.182.101: icmp_seq=1 ttl=56 time=4.107 ms
65008 bytes from 104.27.182.101: icmp_seq=2 ttl=56 time=3.943 ms


This works even without enabling the root account.

PS: Never edit /etc/sudoers directly, always use sudo visudo to do so. visudo applies basic sanity checks on the file when saving, you risk to lock yourself out of sudo if you get things wrong by editing the file directly.