Leonardo
Leonardo

Reputation: 2363

Bash - DoWhile - Read a File content

I need a huge favor from you.

I have to run several times a PHP script, but I have no knowledge of programming in bash.

The script should work like this:

Within a cycle DoWhile ->

The script directory / crawler.php must be tested at least once.

Some of you know how to write this code in Bash? Bash For those who know the code is really simple, but it is very difficult for me because I do not know anything Bash.

I just need this script in my "bash-programming-life. "

Thanks

Upvotes: 0

Views: 679

Answers (2)

Dennis Williamson
Dennis Williamson

Reputation: 360345

#!/bin/bash
file=directory/array.txt

>>"$file"    # create the file if it doesn't exist

until [[ "$(<"$file")" == "0" ]]
do
  php directory/crawler.php
done

Upvotes: 0

johusman
johusman

Reputation: 3472

Something like

php directory/crawler.php
while [[ "$(cat directory/array.txt)" -ne "0" ]]; do
  php directory/crawler.php
done

presuming that the directory/array.txt file only contains a 0 when execution should terminate.

Upvotes: 1

Related Questions