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 6848729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:54:17+00:00 2026-05-27T00:54:17+00:00

I am looking at wpshell – shell, written in PHP (for PHP and WordPress).

  • 0

I am looking at wpshell – shell, written in PHP (for PHP and WordPress).

It seems to be run by following code in bash:

#!/bin/bash

shell=$(dirname $(readlink -f $0))"/wpshell.php"

if [ -t 0 ]; then
    while [ true ]; do
        /usr/local/bin/php $shell
        if [ $? -eq 0 ]; then break; fi
    done
else
    set -f
    read -s input
    echo $input | /usr/local/bin/php $shell stdin
fi

How to adapt this for Windows environment? If at all possible.

  • 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-27T00:54:18+00:00Added an answer on May 27, 2026 at 12:54 am

    Lets look at this piece by piece

    • shell=$(dirname $(readlink -f $0))"/wpshell.php"

      • $0 is the script being called. $(cmd) means take the output of cmd.
      • readlink -f resolves symlinks, so $(readlink -f $0) finds the full path of the script being run, after evaluating any symlinks.
      • dirname /path/to/foo.sh returns the path to the argument (in this case /path/to). So, $(dirname $(readlink -f $0)) is the full path to the directory this script was being run from, after resolving all links.

      • shell=$(dirname $(readlink -f $0))"/wpshell.php" Takes the output of shell=$(dirname $(readlink -f $0)) and appends “/wpshell.php”. So, this whole line just gets the full path to wpshell.php

    • if [ -t 0 ]; then check if STDIN is open and refers to a terminal, and enters the if block if it does

      • while [ true ]; do loops forever until we break. This is so if wpshell crashes or exits with an error, it will automatically restart.
        • /usr/local/bin/php $shell just calls php and passes it the path to wpshell that we found earlier.
        • if [ $? -eq 0 ]; then break; fi check if the last command (/usr/local/bin/php $shell) completed successfully. ?$ is the return code of the last command, and we check if that equals 0, which means no error. If there was no error, wpshell exited cleanly, so we are done, and can break out of our infinite loop and exit.
    • else this block is executed if the STDIN does not refer to a terminal

      • set -f disables glob completion, so things like * are not expanded.
      • read -s input reads a string from the user and stores it in input
      • echo $input | /usr/local/bin/php $shell stdin sends what we just read as the input to wpshell, and tells it to read from that

    Most of this functionality isn’t available on Windows. You would most likely be fine just calling php on wpshell.php. Create wpshell.bat, and put "C:\path\to\php" "C:\path\to\wpshell.php" in it. You can then run wpshell.bat to run wpshell.

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

Sidebar

Related Questions

Looking for feedback on : http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools
Looking for C# class which wraps calls to do the following: read and write
Looking around at different code bases I see a variety of styles: Class interfaces
Looking for simple php class routing, like this: http://fatfree.sourceforge.net/page/routing-engine Is there a ready-made solutions?
Looking for good explanation of why this code raises SyntaxError . def echo(x): return
Looking to pull the category ID of a specific page in WordPress that is
Looking through the getting started guide for scopes, it seems to imply that I
Looking at the missing index DMVs on SQLServer it suggests I add the following
looking really for some advice on how i should handle the following scenario. i
looking in internet how put a shadows to my containers i found this code

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.