I think that you're making it harder than it needs to be.
I don't like exec'ing variables or building command lines, etc. I prefer running this directly:
That way quotes are your friend and not your enemy.
Lee.
Update:
I replaced sendfax in the command line with echo, see below, just to see what echo would print. It printed the rest of line with the quotes. Now I'm totally confused. Why would echo see and print the quotes and sendfax dosen't but only when executed through a variable? This is weird.
FYI, I had escape the "s when I built the command line as you showed.
/Update:
I think I have that right. See the following:
-----
is: Can not open file
-----
The sendfax line is the echo of the variable that will be executed. As you can see the "'s are in the string that will be executed. What it looks like is that when you execute the string somehow the "'s are removed.
BTW, If I remember correctly I had a problem with putting "'s around the dial string but if I removed the Parmacist@ it worked. Don't hold me to this one though as I have to go back and recheck it.
This is driving me nuts.
John Warren
Network Operations Administrator
Prudent Rx Inc.
100 Corporate Pointe, Suite 395
Culver City, CA 90230
( +1.310.642.1700 x121
+1.310.642-1701
**Notice of Confidentiality**
Please note that the information contained in this message may be privileged and confidential and protected from disclosure under the law, including the Health Insurance Portability and Accountability Act (HIPAA). If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited and may subject you to criminal or civil penalties. If you have received this communication in error, please notify the sender by replying to the message and delete the material from any computer.
Thank you,
Prudent Rx, Inc.
On Jun 15, 2007, at 2:30 PM, Lee Howard wrote:
John Warren wrote:
First, I'm new to writing bash scripts.
I have a string name "commandline" that contains the following:
If I do the following in a bash script it fails with "is: Can not open file"
$command
If I remove the ( -c "This is a test fax" ) or change it to ( -c "test" ) it works.
If I execute the same line outside of the script it also works.
Is the Bash script taking out the "'s and if so how do I keep it from doing this?
Sounds to me like you're creating some kind of COMMANDLINE variable and then exec'ing that variable later. In that case you'll need to make sure to escape your quotes so that they don't get eaten by the first parsing when it's placed into $COMMANDLINE...
COMMANDLINE="sendfax -c\"This is a test fax\" -d Pharmacist@13106421032"
Lee.