2

I am trying to make the xdebug stack links to open files directly in netbeans, here is what I have done so far:

  1. I created an executable file /home/david/bin/netbeans.sh (which I chmoded +x) containing:

    #!/bin/bash
    
    url=$2
    file=${url#*\/\/}
    file=${file%?line=*}
    line=${url#*line=}
    
    /home/david/Programs/netbeans-8.1/bin/netbeans --open $file:$line
    
  2. in /etc/php5/apache2/php.ini I added

    xdebug.file_link_format = "netbeans://%f?line:%l"
    
  3. in firebug "about:config" I created a new boolean:

    network.protocol-handler.expose.netbeans => false
    
  4. I created a new url-handler in Gnome's gconf:

    gconftool-2 -t string --set /desktop/gnome/url-handlers/netbeans/command "/home/david/bin/netbeans.sh %s"
    gconftool-2 -t bool --set /desktop/gnome/url-handlers/netbeans/enabled true
    gconftool-2 -t bool --set /desktop/gnome/url-handlers/netbeans/needs_terminal false
    

now when I get an error, the files of xdebug's stack are links of type netbeans:///var/www/html/path/to/file.php, all good.
When I click on one of those links, I get the "Launch Application" window where I have to choose the application to open the file with: I select the executable I created in step 1, i.e.: /home/david/bin/netbeans.sh but I get an error message saying:

/home/david/: does not exist, or is not a plain file

And this is where I am stuck, I don't understand why I get this error and how to solve it.

edit screenshot of gnome config enter image description here

OSdave
  • 378
  • 1
  • 4
  • 16
  • Can you test the command created in 1 by not executing it but writing it to a file? Or even swap it all out for just one line to determine if the file is executed. – TacoV Feb 01 '16 at 06:21
  • Did you use the same user when running gconftool-2? http://stackoverflow.com/questions/11977779/setting-protocol-handler-by-x-scheme-handler-in-centos-opensuse – TacoV Feb 01 '16 at 06:27
  • @TacoV I'm sorry but I don't understand what I should do about your 1st comment. Regarding your 2nd one, I think I did (I always use the same user, and I don't think I sudoed this commands). I've edited the question to include a screenshot of my gnome configuration editor, does that help? I notice the "Key owner" is none, maybe that's the problem? – OSdave Feb 01 '16 at 07:08
  • but you did change the user to david right? – Dimitri Podborski Feb 07 '16 at 13:57
  • @incBrain I tried `gconftool-2 --owner=david /desktop/gnome/url-handlers/netbeans` but no luck – OSdave Feb 07 '16 at 14:12
  • @OSdave It's not clear to me if you have a folder `user` in your `/home` or you just forgot to change user to david somewhere. E.g. in `netbeans.sh` – Dimitri Podborski Feb 07 '16 at 14:16
  • @incBrain sorry about that, I put `user` instead of `david` in the question because I've seen people doing it (for security purpose I suppose). I've edited the question so that it reflects exactly what it is now. – OSdave Feb 07 '16 at 14:21
  • okay, and another thing is that I see that you call `/home/david/bin/netbeans.sh %s` and in the script you are accessing `$2` but it should be `$1` – Dimitri Podborski Feb 07 '16 at 14:33
  • I've just changed it, but now I get: `/path/to/file:2netbeans:/path/to/file does not exist, or is not a plain file.` should we use the chat? – OSdave Feb 07 '16 at 14:39
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/35409/discussion-between-osdave-and-incbrain). – OSdave Feb 07 '16 at 14:50

1 Answers1

1

Okay, so we found the solution for this problem. First of all there was a wrong argument number if the netbeans.sh file. So url=$2 should be url=$1. But also the parsing of the filename and the line number in the script was wrong.

Since the provided string has the form netbeans:///path/to/file?line=[LineNumber] the parsing can be done by:

#!/bin/bash

# extract the protocol
proto="$(echo $1 | grep :// | sed -e's,^\(.*://\).*,\1,g')"
# remove the protocol
url="$(echo ${1/$proto/})"
# get file and line
file="$(echo $url | cut -d\? -f1)" 
line="$(echo $url | cut -d\= -f2)"

/home/david/Programs/netbeans-8.1/bin/netbeans --open $file:$line
Dimitri Podborski
  • 2,505
  • 16
  • 22