QA


Q&A

Q1:

I'm trying to write a long shell script, and it's not working as I expect it to. Are there any tools to help me see exactly what the shell is doing when my script is running?

A1:

Yes. Inserting the special command set -x into your shell script causes the shell to display everything it does afterward, one line at a time, as your script is running. Inserting the special command set +x later in your script turns this debugging feature off again.

Q2:

When I try to use quotes at the command line, I often end up trapped by a strange prompt that doesn't seem to accept any commands. Why?

A2:

If you're stuck at a prompt that looks like a greater-than symbol, it means you've used unbalanced quotes somewhere in your command. They can take the form of mismatched quotation marks (one single and one double) or an uneven number of quotation marks (meaning that you've forgotten to close a set of quotes somewhere), as can be seen in the examples of mismatched quotes below:

 "This text is in mismatched quotes' And so is this word, because there is no closing quote: 'Hi! 

When you are stuck at a prompt that looks like a greater-than symbol, the shell is waiting for a matching close quote for an opening quote that you've entered. Try entering a single quotation mark or a double quotation mark; one of these should return you to the command prompt.

Q3:

I'm trying to experiment with shell scripts, but my script test doesn't seem to do anything at all, no matter what I put in it! Why?

A3:

This is because running a test command that actually exists at /usr/bin/testso it never finds your test script because /usr/bin/test is being executed instead. The easiest solution is to rename your script to something else using the mv command.



    SAMS Teach Yourself Red Hat(r) Fedora(tm) 4 Linux(r) All in One
    Cisco ASA and PIX Firewall Handbook
    ISBN: N/A
    EAN: 2147483647
    Year: 2006
    Pages: 311
    Authors: David Hucaby

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net