Determining WordPress’ Version from the Host’s Command Line?

Given that I can’t access the dashboard/admin pages on my blog (that’s a future question), and that I have shell access to my hosting server, can I find out the current version of WordPress from the command line? I tried grepping for the string ‘@since’ in all the php files in the top level directory … Read more

Access WordPress API Outside of WordPress (command-line PHP)

I have a PHP script that I need to run as a cron job. However this script needs access to the WP API (get_pages(), get_post_meta() and get_permalink() specifically). I’ve followed the instructions at http://codex.wordpress.org/Integrating_WordPress_with_Your_Website, but to no avail. Code: require_once(‘../../../wp-blog-header.php’); $args = array( ‘child_of’ => 2083 ); $pages = get_pages($args); However when I run php … Read more

How do I set a variable to the output of a command in Bash?

I have a pretty simple script that is something like the following: #!/bin/bash VAR1=”$1″ MOREF=’sudo run command against $VAR1 | grep name | cut -c7-‘ echo $MOREF When I run this script from the command line and pass it the arguments, I am not getting any output. However, when I run the commands contained within … Read more

How do I parse command line arguments in Bash?

Say, I have a script that gets called with this line: ./myscript -vfd ./foo/bar/someFile -o /fizz/someOtherFile or this one: ./myscript -v -f -d -o /fizz/someOtherFile ./foo/bar/someFile What’s the accepted way of parsing this such that in each case (or some combination of the two) $v, $f, and $d will all be set to true and … Read more