Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Where am I going wrong with this script???

Hi all,


I'm doing something stupid but can't figure out what - maybe it's jetlag!


Small script to create a sym link to a network share:



#!/bin/bash


zzz= stat -f%Su /dev/console
echo $zzz
ln -s "/volumes/MacServer/Mac Learners" "/Users/$zzz/Desktop/MacLearners"
exit 0


It echos back the corect username for $zzz but does not pass it to the next line to create the alias in the right place. It returns:



invalid location /Users//Desktop/MacLearners

Anybody have enough caffinein their system to fix this?

Xserve, OS X Server

Posted on Oct 31, 2012 10:04 AM

Reply
Question marked as Best reply

Posted on Oct 31, 2012 11:32 AM

This may be a formatting issue on the boards, but your stat command is enclosed in backticks, right?:


zzz=`stat -f%Su /dev/console`


You need the backticks to execute the command, otherwise it won't do what you expect - indeed, running the first line as written echos back the username, so it may be that line's output that you're seeing, more than the echo statement:


#!/bin/bash


zzz=`stat -f%Su /dev/console`

echo $zzz

ln -s "/volumes/MacServer/Mac Learners" "/Users/$zzz/Desktop/MacLearners"

exit 0

2 replies
Question marked as Best reply

Oct 31, 2012 11:32 AM in response to Gerard Allen

This may be a formatting issue on the boards, but your stat command is enclosed in backticks, right?:


zzz=`stat -f%Su /dev/console`


You need the backticks to execute the command, otherwise it won't do what you expect - indeed, running the first line as written echos back the username, so it may be that line's output that you're seeing, more than the echo statement:


#!/bin/bash


zzz=`stat -f%Su /dev/console`

echo $zzz

ln -s "/volumes/MacServer/Mac Learners" "/Users/$zzz/Desktop/MacLearners"

exit 0

Where am I going wrong with this script???

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.