日期:2014-05-16  浏览次数:20902 次

linux命令行怎么读取文本做为命令?
linux命令行怎么读取文本做为命令?

例如 /sss/bbb.txt的内容是

./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-openssl=/usr --with-png-dir --with-jpeg-dir --with-freetype-dir --with-iconv-dir=/usr/local --enable-gd-native-ttf --with-libxml-dir --with-zlib --with-mhash --with-mcrypt --with-ldap --with-ldap-sasl --with-curl=/usr/local --with-curlwrappers --enable-bcmath --enable-calendar --enable-mbstring --enable-ftp --enable-zip --enable-sockets --enable-exif --enable-zend-multibyte --enable-fpm --with-fpm-user=www --with-fpm-group=www make && make install

我想在命令行下,直接读取bbb.txt的内容,然后把它做为命令来执行
我在群里问了 有人说用eval 我试了试没成功


------解决方案--------------------
C/C++ code
#! /bin/bash

./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-openssl=/usr --with-png-dir --with-jpeg-dir --with-freetype-dir --with-iconv-dir=/usr/local --enable-gd-native-ttf --with-libxml-dir --with-zlib --with-mhash --with-mcrypt --with-ldap --with-ldap-sasl --with-curl=/usr/local --with-curlwrappers --enable-bcmath --enable-calendar --enable-mbstring --enable-ftp --enable-zip --enable-sockets --enable-exif --enable-zend-multibyte --enable-fpm --with-fpm-user=www --with-fpm-group=www make && make install