Command Line Preview Running Application


I want to run the menu command “Preview” --> “Preview Running Application” from the command line in a terminal. Fairly sure it is an easy command, just can’t figure out what it is. I know I can start the Apache2 server with this command

service apache2 start

Any suggestions?

If it can be done, what is the extra command to have the browser open in a new window and not the cloud9 workspace window.


There is no command for this yet.
It is possible to add a preview command to c9 cli utility
It might be something like c9 preview [-n] [path] with optional path (previewing app if there is no path sent)
and -n flag for opening a new tab


That is a bit more advanced than I was looking for, did not realize menu commands could not be accessed from the command line.

Oh well not a big deal.

If someone finds a way, drop a comment please.


From the command line I can write a clickable url such as

echo “

Anyone who knows the url for their workspace can simple write it in an echo in a bash file, but I want the bash file to be on github so a new user can make a clickable url. The problem is, that I will need variables for the workspace name and the userlogin.

I know that these variables work


ubuntu 8080 /home/ubuntu userNane-workspaceName-randomNumber




Any idea of variables that can be used to make a user URL?

In the form

echo “

I may have answered this myself. I think $HOSTNAME has all the information needed I just have to figure out how to parse it in a bash file.

Any easier suggestions?


That was fast. Lucky google search.

gave me IFS=- read var1 var2 <<< ABCD-1234

so,this works

IFS=- read var1 var2 var3 var4<<< $HOSTNAME

echo "http://$var2-$var3-$"


Dang it. the above is dependent on the number of dashes in the workspace name. So it now becomes much more confusing.

This works but only for up to 3 dashes in the workspace name, can someone figure out how to do it as a loop so it would work for any number of dashes in the workspace name

echo "$y"
echo "${#y}"

if [ ${#y} = 4 ]; then
    IFS=- read var1 var2 var3 var4 var5 <<< $HOSTNAME
    echo "http://$var2-$var3-$var4-$"

if [ ${#y} = 3 ]; then
    IFS=- read var1 var2 var3 var4 <<< $HOSTNAME
    echo "http://$var2-$var3-$"

if [ ${#y} = 2 ]; then
    IFS=- read var1 var2 var3 <<< $HOSTNAME
    echo "http://$var2-$"


you can use $C9_HOSTNAME for this

c9 adds several other environment variable too all prefixed with C9_
typing echo $C9_<Tab> in terminal gives

$C9_EMAIL        $C9_FULLNAME     $C9_HOSTNAME     $C9_IP          
$C9_PID          $C9_PORT         $C9_PROJECT      $C9_SHARED      
$C9_SH_EXECUTED  $C9_UID          $C9_USER 


But I had a lot of fun writing 16 lines of poorly made code that can be replaced with one well written line.

echo "http://$C9_HOSTNAME"

Thanks @harutyun I think I will ask for you by name next time.


Any suggestions how to view $C9_HOSTNAME from within node.js


does not replace the variable. Other ideas do also not seem to work



use process.env.C9_HOSTNAME


Sweet. This line works great