0

I need to have a script that will execute "system_profiler -detailLevel full" command in a remote mac machine. While this is going on, the user on the remote machine should not know that there is something happening.

I tried the following applescript:

tell application "Terminal" of machine "eppc://<ip address of remote machine>"
    activate
    do script "system_profiler -detailLevel full >> /$HOSTNAME.txt" 
end tell

This activates the terminal app on the desktop and hence a bad idea, as user working on that remote machine is interrupted. I want this to happen in the background.

I want a shell script (not an applescript) that will take the name of hostnames from a text file stored on the same location where the shell script is. It will then go to each host from that list of hostnames, execute the system_profiler command and copy the text file having the output of the command ($HOSTNAME.txt file) back to the machine from where the shell script was executed.

The file copying should be done without ssh,scp etc.

3
  • Why do you not want to use ssh, scp etc? Might be difficult to access remote systems otherwise on shell level.
    – nohillside
    Jul 6, 2014 at 8:29
  • yes i understand. What i have come accross that there are commercial products like SAM tools, which gather data from remote mac systems without authentication prompts..Hence i want to do it with scripting. SSH.SCP would require authentication everytime i connect to a remote machine. Jul 9, 2014 at 6:05
  • There is some kind of authentication/autorization required irregardless of the tools used (even for Applescript). ssh and friends won't require additional authentication once you've set up public/private key pairs for all connections required.
    – nohillside
    Jul 9, 2014 at 6:09

1 Answer 1

1

For reading a text file of hostnames into an AppleScript list, see Read textfile into list in Applescript.

For looping over hostnames within your AppleScript list see An AppleScript list iterate/loop example:

set myList to {"Hello", "Goodbye", "I must be going"}
repeat with theItem in myList
  say theItem
end repeat

do shell script

To avoid launching Terminal.app, use the do shell script command:

tell machine "eppc://<ip address of remote machine>"
    do shell script "system_profiler -detailLevel full > /tmp/sysprofile.txt"
end tell

This can be run without launching a supporting graphical application.

I am assuming you can not access the remote host via secure shell, only via Remote AppleEvent access eppc.

Returning the File

Read the contents of the file within your AppleScript's tell machine block and save it locally outside of the tell machine block.

Alternatively, have you considered transferring back the system profile file via ssh or scp? Consider having your AppleScript to connect to your Mac and copy back the collected system profile.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .