Setting a variable to the result of a terminal command within an applescript I'm trying to make a script that ejects all connected external drives and does not move on until they are all disconnected.

The main problem I'm having is being able to set the variable vol_count to the result of the following script:

tell application "Terminal"
    cd /Volumes
    ls | wc -l
end tell


I also have not tested that script, but I assume that's how you run a terminal command from within an applescript.

Follow up question:

How would I then have it eject all but two disks (my hard drive is partitioned into two disks)?

on run {}

    tell application "Finder"
        set vol_count to do shell script "cd /Volumes; ls | wc -l"

        eject the disks

        repeat until vol_count is equal to 2
            set vol_count to do shell script "cd /Volumes; ls | wc -l"
        end repeat
    end tell
end run
try:

set dontEject to {"Mac OS X", "Time Machine", "Media", "home", "net"}
set myDisks to list disks

repeat with aDisk in myDisks
    if aDisk is not in dontEject then tell application "Finder" to eject aDisk
end repeat