我之所以这样问,是因为我正试图在我的朋友频道中摆弄一个irc机器人,但无论如何都不能让它正常工作
基本上这个机器人是phenny,它有一个python解释器,我试图让它打印出字符串"linux open source linux open source“100次。
x = 9000; while x >1: x = x - 1; print "linux"
和
x=9000; while x>0: print 'linux'; x = x-1 .
到目前为止我已经尝试过了,我不确定如何才能在一行代码中完成所有这些。
我想问一下linux中的ftp连接,如何使用终端检查linux中的ftp匿名连接?我使用while循环读取vsftpd.conf文件,就像这样
while read line
do
if [ Anonymous_enable=YES ];
then echo " Accept connection"
elif [ Anonymous_enable=NO ];
then echo "Not Accept"
fi
done<vsftpd.conf
下面的bash脚本存在简单的语法问题。我不知道用什么语法将if语句嵌套到while语句中,或者使用bash shell脚本(对于所有linux都是新的)是否可能:
#!/bin/bash
myCombo=$((RANDOM%99999+10000));
echo ${myCombo};
myCracker=00000;
while [ (($myCracker<=99999)) ]; do
if [ $myCracker -eq myCombo ]
then
echo "The combination is " ${myCracker
为了逐行处理bash中的文本文件,我通常实现一个while循环,如下所示:
function doSomething() {
local inputFile="$1"
local fd=""
local line=""
exec {fd}<"$inputFile" # open file
echo "Opened ${inputFile} for read using descriptor ${fd}"
while IFS='' read -r
我不习惯编写Bash脚本,Google也没有帮助找出这个脚本的错误所在:
#!/bin/bash
while read myline
do
done
echo "Hello"
while read line
do
done
exit 0
我得到的输出是:
./basic.agi: line 4: syntax error near unexpected token 'done'
./basic.agi: line 4: 'done'
我的bash版本是:
GNU bash, version 3.2.25(1)-release (i686-re
我有一个“永远运行”的应用程序。为了实现这一点,我的代码在while(true)循环下。
while(true){
//My code is here
//What it does is that it calls some Url,
//gets xml, parses it and stores the values to a db.
}
此应用程序作为java应用程序运行,并在Redhat Linux上的jdk 5上运行。一两天后,我意识到日志的活动甚至是5天前的,这意味着它在5天前停止了工作。但是当我检查机器中的java进程时,这个应用程序显示它正在运行。
问
我的工作是机器人,它必须控制使用无线串行通信。机器人在微控制器上运行(通过燃烧一个.hex文件)。我想用我的Linux () PC来控制它。我是新来的串口编程。我能够发送数据,但我不能读取数据。
在微控制器上运行的几段代码:
函数发送数据:
void TxData(unsigned char tx_data)
{
SBUF = tx_data; // Transmit data that is passed to this function
while(TI == 0) // Wait while data is being transmitted
;
}
我在Linux和solaris下运行相同的脚本。下面是脚本:
#!/bin/sh
index=0
ls /tmp | grep e |
while read fileWithE
do
echo $fileWithE
index=`expr $index + 1`
done
echo "index is $index"
由于while循环在子while中运行,所以在solaris和linux中,我期望'index is 0‘作为输出。但是在solaris中,$index是/tmp下包含'e‘的文件的实际数量。那么,虽然循环不会在solaris下的
我不清楚在while循环中捕获GeneratorExit的行为,以下是我的代码:
# python
Python 2.6.6 (r266:84292, Sep 4 2013, 07:46:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def func():
... while True:
..
void cpu_idle (void)
{
/* endless idle loop with no priority at all */
while (1) {
void (*idle)(void) = pm_idle;
if (!idle)
idle = default_idle;
if (!current->need_resched)
idle();
schedule();
check_pgt_cache();
}
}
此代码存
我现在的代码是
while true; do ./program; done;
我现在没有访问linux机器的权限,唯一的方法就是在实时服务器上提出请求,我不想测试和破坏一些东西,所以如果我能得到一些帮助,我会很高兴的。
如果我想让我的程序在每次重新启动后的2秒内休眠,它应该是这样的吗?
while true; sleep(2); do ./program; done;
每天有4 4gb的内存使用量,而且根本不会清理
具有以下php脚本:
while(1){
sleep(15);
$data = // get data
foreach ($data as $d){
//get the db status
// make api call in same ip to update server
// write log
}
}
service linux code (via docker):
[program:cron]
command=/bin/bash -c "e
我正在写一个bash脚本来启动一个不确定的程序。程序的运行时间未知。该脚本还将启动一个while循环,用于使用linux命令或perf以1秒的方式记录某些内容。
./my_app &
$i=1
while true;
do
perf stat -a -A -e writeback:writeback_dirty_page sleep $i >> out
done
如何在my_app完成时停止while循环?谢谢。
我在Linux服务器上运行了以下Java代码: while (true) {
int a = 1+2;
} 它导致一个CPU核心达到100%的使用率。我对此感到困惑,因为我了解到CPU通过时间拆分来处理任务,这意味着CPU将在一个时隙内完成一个任务(CPU时间范围调度器)。如果有10个时隙,则while true任务应该最多使用10%的CPU使用率,因为其余90%将分配给其他任务。那么为什么是100%呢?
我正在试图弄清楚为什么现在这个坏了,因为我让它工作了,但我不确定哪里出了问题。我正在尝试从一个已经打开的文件中执行一个简单的getline,然而,编译器总是给我错误。我试过找其他有这些问题的人,但我找不到其他有这些问题的人。有什么建议吗?
void Foo::bar(ifstream &inputFile)
{
// Read in the data, parse it out, and
// call loadQueue
string input;
do {
getline(inputFile, input);
loadQueue(input);
}whil
在我的项目中,我使用linux shell来获取一些数据。 我在运行脚本时发现了一个错误。 我编写了一个test.sh来测试我的代码: [john@node04 findApp]$ cat test.sh
while read line
do
echo $line
while read Row
do
done < daysnameFiles
done < allUserAppIn 当我运行测试代码时,我得到语法错误 [john@node04 findApp]$ sh test.sh
test.sh: line 6: syntax error n