A low-level error related to the here documents when running the Ksh script on Aix

Source: Internet
Author: User
Tags oracle database

Today, write a ksh script on Aix that collects Vmstat information on a regular basis and puts it into an Oracle database for query analysis, as follows:

#!/usr/bin/ksh

Export Oracle_home=/home/oracle/database
Export path= $ORACLE _home/bin: $PATH
Server_name= ' Uname-a|awk ' {print $} '
Typeset-u server_name
Export server_name

sample_time=300

While True
Todo
Vmstat ${sample_time} 2 >/tmp/msg$$
Cat/tmp/msg$$|sed 1,3d| awk ' {printf ('%s%s%s%s '%s\n%s ', $, $, $14, $, $16, $17)} '
While read Runque page_in page_out user_cpu system_cpu idle_cpu wait_cpu
Todo
$ORACLE _home/bin/sqlplus-s test/test@sid<<eof
INSERT into Test.test$vmstat values (
Sysdate,
$SAMPLE _time,
' $SERVER _name ',
$RUNQUE,
$PAGE _in,
$PAGE _out,
$USER _cpu,
$SYSTEM _cpu,
$IDLE _cpu,
0
);
EXIT
Eof
Done
Done
rm/tmp/msg$$

As a result, the tragedy occurred on the last "EOF", for the code format, I added EOF before the tab, but this is not allowed by EOF, the following error occurred:

./get_vmstat.sh[13]: 0403-057 Syntax error at line: ' < ' are not matched

EOF represents the end of this documents. Note that this is not the same as writing a C program to indent EOF to the right for beauty, because the shell stipulates that EOF must be the only occurrence of the line, not even a space. Therefore, this EOF is temporarily highlighted in this line. (This problem can be solved by changing the input operator to "<<-", but this is harmless).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.