Reputation: 31
I'm using a script to modify some mailboxes on a Zimbra server hosted on a Ubuntu server. This script checks if mailbox exists and, if so, proceeds the required change.
I get the error
scriptname.sh: 4: Syntax error: Bad fd number
Here's the script:
#!/bin/bash
email=$1
echo "Looking for $email"
/opt/zimbra/bin/zmprov ga "$email" displayName > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Mailbox not found on this server"; exit 2;
fi
/opt/zimbra/bin/zmprov ModifyAccount "$email" zimbraMailTransport smtp:server.domain.com:25
if [ $? -ne 0 ]; then
echo "Error updating Transport.";
exit 3;
fi
echo "Transport updated";
The error is related to this line:
/opt/zimbra/bin/zmprov ga "$email" displayName > /dev/null 2>&1
I'm quite a newbie on bash, so.. I don't really know how to debug this.
Upvotes: 2
Views: 4783
Reputation: 19415
For an unknown reason, a \r was added at the end of each line of the script.. Removed it with notepad++, and it worked like a charm. – Ashina
Upvotes: 2