<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">I've been working on a way to send faxes from a bash script. It requires changing what parameters are used for each command. I keep having problems with quoted strings passed to the command.<DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><P style="margin: 0.0px 0.0px 12.0px 0.0px"><FONT class="Apple-style-span" size="4"><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3px;">I've c</SPAN></FONT><SPAN class="Apple-style-span" style="font-size: 13.3px;">reated a really short test script which fails on my system.</SPAN></FONT></P><DIV>commandline="sendfax -f <A href="mailto:noreply@prudentrx.com">noreply@prudentrx.com</A> -n -x \"Test fax\" -d 13105551212 /etc/hosts"</DIV><DIV>echo "Commandline: $commandline"</DIV><DIV>$commandline</DIV><P style="margin: 0.0px 0.0px 12.0px 0.0px"><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3px;"><BR class="khtml-block-placeholder"></SPAN></FONT></P><P style="margin: 0.0px 0.0px 12.0px 0.0px"><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3px;">When I run the script I get the following:</SPAN></FONT></P><DIV>Commandline: sendfax -f <A href="mailto:jwarren@prudentrx.com">jwarren@prudentrx.com</A> -n -x "Test fax" -d 13105551212 /etc/hosts</DIV><DIV>fax": Can not open file</DIV><P style="margin: 0.0px 0.0px 12.0px 0.0px"><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3px;"><BR class="khtml-block-placeholder"></SPAN></FONT></P><P style="margin: 0.0px 0.0px 12.0px 0.0px"><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3px;">As you can see the sendfax command is not picking up the "'s around the "Test fax" string so it picks up the Test but thinks fax is the file to fax.</SPAN></FONT></P><P style="margin: 0.0px 0.0px 12.0px 0.0px"><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3px;">If you take the string and execute it from the command line it works. There is something about executing it from a string within a script that causes it to fail.</SPAN></FONT></P><P style="margin: 0.0px 0.0px 12.0px 0.0px"><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3px;">I tried doing the same thing using mail as the command with a quoted subject. Same thing happens, it break after the first space in the subject when executed from a sctips.</SPAN></FONT></P><P style="margin: 0.0px 0.0px 12.0px 0.0px"><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3px;">I've tried using both sh and exec commands but still no joy.</SPAN></FONT></P><P style="margin: 0.0px 0.0px 12.0px 0.0px"><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3px;">I really need to be able to build a command line with quoted text. Anyone have a way to work around this.</SPAN></FONT></P><P style="margin: 0.0px 0.0px 12.0px 0.0px"><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3px;"><BR class="khtml-block-placeholder"></SPAN></FONT></P><P style="margin: 0.0px 0.0px 12.0px 0.0px"><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 13.3px;">Thanks</SPAN></FONT></P><FONT class="Apple-style-span" size="4"><FONT class="Apple-style-span" size="3"><BR class="Apple-interchange-newline"></FONT></FONT></SPAN></SPAN></SPAN></SPAN> </DIV><BR><DIV><DIV>On Jun 15, 2007, at 3:43 PM, Lee Howard wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I think that you're making it harder than it needs to be.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I don't like exec'ing variables or building command lines, etc.<SPAN class="Apple-converted-space">  </SPAN>I prefer running this directly:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">sendfax -f "$FROMLINE" -n -D -i "$INFO" -c "$COMMENTS" -d "$DIAL" $FILE</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">That way quotes are your friend and not your enemy.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Lee.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">John Warren wrote:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> <BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Update:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">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.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">echo -f <A href="mailto:jwarren@prudentrx.com">jwarren@prudentrx.com</A> <<A href="mailto:jwarren@prudentrx.com">mailto:jwarren@prudentrx.com</A>> -n -D -i 010000TESTFL -c "This is a test fax" -d Parmacist@13106421032 /var/spool/hylafax/windows/jobs/QueuedT/00TESTFL.pdf</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">FYI, I had escape the "s when I built the command line as you showed.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">/Update:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I think I have that right. See the following:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-----</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">sendfax -f <A href="mailto:jwarren@prudentrx.com">jwarren@prudentrx.com</A> <<A href="mailto:jwarren@prudentrx.com">mailto:jwarren@prudentrx.com</A>> -n -D -i 010000TESTFL -c "This is a test fax" -d Parmacist@13106421032 /var/spool/hylafax/windows/jobs/QueuedT/00TESTFL.pdf</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">is: Can not open file</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-----</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">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.<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">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.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">This is driving me nuts.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">John Warren</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Network Operations Administrator</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Prudent Rx Inc.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">100 Corporate Pointe, Suite 395</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Culver City, CA 90230</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">( +1.310.642.1700 x121</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+1.310.642-1701</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">E: <A href="mailto:jwarren@prudentrx.com">jwarren@prudentrx.com</A> <<A href="mailto:jwarren@prudentrx.com">mailto:jwarren@prudentrx.com</A>></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">**Notice of Confidentiality**</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">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.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Thank you,</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Prudent Rx, Inc. <SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">On Jun 15, 2007, at 2:30 PM, Lee Howard wrote:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> <BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">John Warren wrote:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> <BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">First, I'm new to writing bash scripts.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I have a string name "commandline" that contains the following:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">sendfax -f <A href="mailto:jwarren@prudentrx.com">jwarren@prudentrx.com</A> <<A href="mailto:jwarren@prudentrx.com">mailto:jwarren@prudentrx.com</A>> <<A href="mailto:jwarren@prudentrx.com">mailto:jwarren@prudentrx.com</A>> -n -D -i 010000TESTFL -c "This is a test fax" -d Parmacist@13106421032 /var/spool/hylafax/windows/jobs/QueuedT/00TESTFL.pdf</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">If I do the following in a bash script it fails with "is: Can not open file"</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">$command</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">If I remove the<SPAN class="Apple-converted-space">  </SPAN>(<SPAN class="Apple-converted-space">  </SPAN>-c "This is a test fax"<SPAN class="Apple-converted-space">  </SPAN>)<SPAN class="Apple-converted-space">  </SPAN>or change it to<SPAN class="Apple-converted-space">  </SPAN>(<SPAN class="Apple-converted-space">  </SPAN>-c "test" <SPAN class="Apple-converted-space">  </SPAN>) it works.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">If I execute the same line outside of the script it also works.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Is the Bash script taking out the "'s and if so how do I keep it from doing this?</DIV> </BLOCKQUOTE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Sounds to me like you're creating some kind of COMMANDLINE variable and then exec'ing that variable later.<SPAN class="Apple-converted-space">  </SPAN>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...</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">COMMANDLINE="sendfax -c\"This is a test fax\" -d Pharmacist@13106421032"</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Lee.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> </BLOCKQUOTE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> </BLOCKQUOTE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> </BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>