红联Linux门户
Linux帮助

Neoshine linux 中 << 的妙用

发布时间:2007-03-07 01:12:05来源:红联作者:ckernel
  记得自己曾经一度因为不能实现终端shell脚本不能够实现对程序的输入进行自动填充而困惑,今天终于解惑了;采用的关键命令就是<<;

  下面我就用一个试验来完成这次测试--

  首先编写一个测试程序,此测试程序的要求就是要有输入变量的需求;

  程序如下:

/**//***************************************************************************
* main.c
* Mon Mar 5 17:19:11 2007
* Copyright 2007
* Email lsosa.BIT
****************************************************************************/

#include

int main(int argc, int argv)...{
//
char a;
a = getchar();
printf("a=%c ", a);
}

  编译完成;生成test程序;

  运行测试--

  [root@localhost test]# ./test
  a // input;
  a=a // output;

  测试成功;

  下面编写脚本;

  #! /bin/sh
  #lsosa.BIT
  ./test << EOF
  s
  EOF

  运行之,成功,yes,困惑我这么长时间的问题终于解决了,这里将测试过程贴出来,就免去了大家的测试过程;也是做个备忘了。
文章评论

共有 0 条评论