need a script

Joined
Feb 27, 2006
Messages
33
Reaction score
0
Points
6
sorry if this is wrong place.

i need a script for renaming the existing Entourage identities over a network for different users, each one has their own mac.

can anyone help? or suggestions? or some where else to look?
 
Joined
Jul 2, 2007
Messages
3,494
Reaction score
204
Points
63
Location
Going Galt...
Your Mac's Specs
MacBookAir5,2:10.13.6-iMac18,3:10.13.6-iPhone9,3:11.4.1
Assuming you have passwordless ssh set up on your systems, you could do something like:

#!/bin/ksh

for i in hostname1 hostname2 hostname3 hostname3; do
echo $i
ssh $i "mv /path/to/file/filename /path/to/file/newfilename"
done

You would need to supply your own shell (csh, ksh, bsh) value and would need your hostnames of course. Add as many hostnames as needed and seperate them with a press of the spacebar and nothing else. If you don't have passwordless ssh set up, it will still work, but you will be prompted for the password on each system login. The above script moves the original filename (you supply the name) and renames it to newname (you supply that name as well).
 
Joined
Jul 2, 2007
Messages
3,494
Reaction score
204
Points
63
Location
Going Galt...
Your Mac's Specs
MacBookAir5,2:10.13.6-iMac18,3:10.13.6-iPhone9,3:11.4.1
You could also do a pretty inglorious script in the form of an execuatable file which contains a bunch of line like this:

ssh hostname1 "mv /home/userA/filename /home/userA/newfilename"
ssh hostname2 "mv /home/userB/filename /home/userB/newfilename"
ssh hostname3 "mv /home/userC/filename /home/userC/newfilename"
ssh hostname4 "mv /home/userD/filename /home/userD/newfilename"
etc...

Make sure it's permissions are set to 775 or something executable by whoever you are running it as... No the most creative script, but it should work. When you ssh in it will be as whatever user you are logged in as at the time on the system you are running the script from. If that user doesn't exist on the other systems, it won't work. You would need to change the lines to:

ssh user@hostname "mv /home/user1/filename /home/user1/newfilename"

where user is a user that exists on the target system. You would need to know the password as well.
 
OP
T
Joined
Feb 27, 2006
Messages
33
Reaction score
0
Points
6
ok a bit more info

how can i run it? can i use apple remote desktop

basically we have about 50 macs, people login via active directory. we have a main admin account on each mac.

so when i need to rename the entourage database file how can this be possible, somtimes there is more then one account on a mac.
 
Joined
Jul 2, 2007
Messages
3,494
Reaction score
204
Points
63
Location
Going Galt...
Your Mac's Specs
MacBookAir5,2:10.13.6-iMac18,3:10.13.6-iPhone9,3:11.4.1
Ah, I see. Based on the question, I thought you were a Scripter or Unix-type. To run the scripts just make sure that, in the terminal window, you are in the directory the script is located in and type "./" without the quotes in front of the script name:
./rename-script.ksh
-The above scripts were just models to work off of. I was assuming you or someone at your company was already familiar with scripting and just had writer's block.
-You would need to run them from the command line on a Mac or a Unix/Linux box that is on the same network or has access to the subnets these systems are located on.
-You would also need to enable a remote protocol like rsh, ssh, etc... to allow the connections. You can use PuTTY.exe (a free download) from a Windows box to do the connection and could locate the script in a shared directory or NFS filesystem on your network. You could also just do a small script that batches out a copy to each machine of the script you wish to run.
for 1 in hostname1 hostname2 etc; do
scp -p scriptname.ksh $i:/$HOME or $i:/shared/directory/path or whatever directory you have access to

-The scripts would do what you need to do with some tweaking, in regards to the multiple accounts. If you are not familiar with scripting, I'd suggest having the vendor who sold you the machines crank out something for you. Should take less than an hour if they can remote in to your systems.
-For example, you could output all the account login names and computer hostnames into a separate file and use it for the $i input in the example above. So you would have a line in your script that reads from that file those values from the file into the script:
while read rec_line
do
SRC_AND_TGT=`echo $rec_line | awk '{print "ssh "$1"@"$2}'`
This would generate the ssh user@hostname part of your script which could be passed as the values into the command that logs you on to the system.
-Since you now have the username, then you also have the path for each user for your script and can use system variables like ~ and $HOME or just insert the $1 into the path in your script.
ie: cd $HOME/Microsoft/path/etc... or mv /home/$1/Microsoft/path/etc...
This way you don't need to type in every user name into every path by hand, which would probably take more time than you want.
-I'm useless with GUI's so if you are trying to automate this via a GUI, I'm afraid I'm of little use.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top