Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6598247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:19:09+00:00 2026-05-25T18:19:09+00:00

I just started learning PHP. I’m following phpacademy’s tutorials which I would recommend to

  • 0

I just started learning PHP. I’m following phpacademy’s tutorials which I would recommend to anyone. Anyways, I’m using XAMPP to test out my scripts. I’m trying to write a bash script that will start XAMPP and then open firefox to the localhost page if it finds a specific string, “XAMPP for Linux started.”, that has been redirected from the terminal to the file xampp.log. I’m having a problem searching the file. I keep getting a:

grep: for: No such file or directory

I know the file exists, I think my syntax is wrong. This is what I’ve got so far:

loaded=$false
string="XAMPP for Linux started."

echo "Starting Xampp..."

sudo /opt/lampp/lampp start 2>&1 > ~/Documents/xampp.log

sleep 15

if grep -q $string ~/Documents/xampp.log; then

    $loaded=$true
    echo -e "\nXampp successfully started!"

fi

if [$loaded -eq $true]; then

    echo -e "Opening localhost..."
    firefox "http://localhost/"

else

    echo -e "\nXampp failed to start."
    echo -e "\nHere's what went wrong:\n"
    cat ~/Documents/xampp.log

fi
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:19:10+00:00Added an answer on May 25, 2026 at 6:19 pm

    In shell scripts you shouldn’t write $variable, since that will do word expansion on the variable’s value. In your case, it results in four words.

    Always use quotes around the variables, like this:

    grep -e "$string" file...
    

    The -e is necessary when the string might start with a dash, and the quotes around the string keep it as one word.

    By the way: when you write shell programs, the first line should be set -eu. This enables *e*rror checking and checks for *u*ndefined variables, which will be useful in your case. For more details, read the Bash manual.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I haven't officially started learning PHP, just skimming through a couple tutorials and I
I've just started learning Qt, using their tutorial. I'm currently on tutorial 7, where
I just started learning Zend. I managed to get the basic working (using zf
I just started learning C++ and am currently using codeblocks. I want to write
I have just started learning PHP, and here's my first doubt... Both of these
I've just started learning CodeIgniter, and I'm following this authentication tutorial by nettuts+. I
I just started learning php today, so exciting : p not really sure what
I have just started learning coding and PHP so I have been looking at
I just started learning Zend (& OO PHP for that matter), I have spent
I've just started learning aboud PDO and prepared statements (which sure seem to beat

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.