The pathname can be specified in two ways: For example, in " /usr/lib/jvm/jdk1.7.0_07/bin/javac", the pathname is " /usr/lib/jvm/jdk1.7.0_07/bin/" and the filename is " javac". To reference a file, you need to provide the pathname (directory and sub-directories names) and the filename. In other words, ~/Downloads is the same as /Users//Downloads. You can use a special notation " ~" to denote your home directory.
Their full filenames are /Users//Downloads, /Users//Documents, respectively. Your home directory ( /Users/) contains sub-directories such as Downloads, Documents. Users/peter, /Users/paul in macOS or /home/peter, /home/paul in Ubuntu. The users' home directories are allocated under /Users (for macOS), or /home (for Ubuntu), with a sub-directory name the same as the username, e.g. Each user on the system is allocated a directory for storing his files, known as home directory. Unix is a multi-user operating system (although most of you, in particular the Mac users, use it as a single-user personal computer). Notes: Windows use " \" (back slash) as the directory separator, and may contain multiple root directories - one for each drive (e.g., c:\, d:\).
Hard drives are mounted somewhere under the root directory. There is only one root directory for the entire Unix/macOS's file system. The sub-directories are also separated by a " /". The leading " /" (forward slash) denotes the root directory. Root Directory ( /)Ī file is identified via the directories and filename, e.g., " /usr/lib/jvm/jdk1.7.0_07/bin/javac". A sub-directory may contain sub-sub-directories and files. A directory may contain sub-directories and files. The directories are organized in a hierarchical tree structure, starting from the root directory. Hosts.Files are organized in directories (aka folders).
Todo.txt containing the commands (1 command/line) You still have to set the variable user in the script to your login in the script file you specify each command line with full pathname
The script assumes you have thesame $user on each $host it will prompt you once for the password which you can enter without it being displayed and it will try to log in into each host and execute the commands, logging _everything_ in $host.output in your current working directory This TCL/expect script ssh-s into each host listed in $hostfile and executes all the commands in $scriptfile I ran into this problem myself when I had to collect system information on a decent amount of hosts so I wasted an evening coming up with something that'd do the job for me I'd comment out the echo lines, as I was using them for debugging. Quick and dirty, but it did what I needed it to do.
Now your FTP server will have a directory full of text files with machine serial numbers in them. Then it FTPs that file to a server you specify and deletes the text file on the machine. It basically creates a text file on the machine it's running on, names it after the machine's hostname, puts the machine's hostname in the file, and greps the output of system_profiler for anything with "serial number" in the line and throws it in the text file as well.
#! /bin/tcshset FTP_ADDRESS=set FTP_LOGIN=set FTP_PASSWORD=set FTP_PATH=echo "Changing to home directory."cd ~echo "Setting hostname variable."set MAC_NAME=$HOSTecho "Creating text file."touch $MAC_NAME.txtecho "Writing hostname to file."echo $MAC_NAME > ~/$MAC_NAME.txtecho "Writing return carriage to file."echo "" > ~/$MAC_NAME.txtecho "Writing grepped serial number to file."system_profiler | grep -i "serial number" > ~/$MAC_NAME.txtecho "FTPing the file."curl -T ~/$MAC_NAME.txt -u $FTP_LOGIN:$FTP_PASSWORD ftp://$FTP_ADDRESS/$FTP_PATHecho "Removing original text file."rm ~/$MAC_NAME.txtecho "Complete!"This can be prettied up, so any changes are welcome. Read the rest of the hint for the script. This has been tested with OS X 10.2.x with the default C shell. Then you can send and run it via Remote Desktop.
You can run the script remotely via telnet/ssh, or you can make a package and have this script run as the pre /post install script. Edit the $FTP_ADDRESS, $FTP_LOGIN, $FTP_PASSWORD, and $FTP_PATH variables and you're done. You must have FTP service turned on on a machine that the other Macs can hit. I needed a way to get machine serial numbers on my network and that feature is not in Remote Desktop, so I decided to do it my own way.