Make link open target file, not file at link location

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
2
down vote

favorite












Sorry for the tags. I don't know whih one applies. Please remove not pertaining ones, then delete this line. Or comment, and I'll do it myself.



Background



I want to put a link to a file located in /home/myname/some/path/file.tex on my desktop. This TeX file calls other TeX files inside it. Now, when I open the link, which is located on the desktop, my TeX editor, it says I opened the file /home/myname/Desktop/file.tex. I can't compile this file, because the other TeX files the main TeX file relies upon are not located where the program expects them.



Main question



How can I make a link file open the target file in its actual location instead of on the desktop?



EDIT



The solution advertised here does not work as intended. With



#!/bin/bash
exec /home/myname/some/path/file.tex "$@"


I get



/tmp/geany_run_script_JVX1HZ.sh: 7: /tmp/geany_run_script_JVX1HZ.sh: ./open-file.sh: Permission denied


—----------------
(program exited with code: 126)
Press return to continue


Where open-file.sh is the wrapper script located on my desktop.



EDIT 2



Although, if I open a terminal and do



chmod a+x ./open-file.sh


and change exec to texstudio, which incidentally is the program I use to open .tex files, then I can open a terminal and do



bash open-file.sh


it will launch TeXStudio with the desired file loaded in the desired target location. I still can't just double-click open-file.sh on my desktop, since that will open my text editor, letting me edit the bash script. I want to double-click the open-file.sh script file and have TeXStudio open up my file.tex file.



### EDIT 3



From this question, I deduct that I have done everything right and the file should be clickable and be executed upon clicking. Unfortunately, it doesn't. I think my permissions are correct, afaik



enter image description here



and same here



-rwxr-xr-x me me 94 Apr 27 12:00 open-file






share|improve this question


























    up vote
    2
    down vote

    favorite












    Sorry for the tags. I don't know whih one applies. Please remove not pertaining ones, then delete this line. Or comment, and I'll do it myself.



    Background



    I want to put a link to a file located in /home/myname/some/path/file.tex on my desktop. This TeX file calls other TeX files inside it. Now, when I open the link, which is located on the desktop, my TeX editor, it says I opened the file /home/myname/Desktop/file.tex. I can't compile this file, because the other TeX files the main TeX file relies upon are not located where the program expects them.



    Main question



    How can I make a link file open the target file in its actual location instead of on the desktop?



    EDIT



    The solution advertised here does not work as intended. With



    #!/bin/bash
    exec /home/myname/some/path/file.tex "$@"


    I get



    /tmp/geany_run_script_JVX1HZ.sh: 7: /tmp/geany_run_script_JVX1HZ.sh: ./open-file.sh: Permission denied


    —----------------
    (program exited with code: 126)
    Press return to continue


    Where open-file.sh is the wrapper script located on my desktop.



    EDIT 2



    Although, if I open a terminal and do



    chmod a+x ./open-file.sh


    and change exec to texstudio, which incidentally is the program I use to open .tex files, then I can open a terminal and do



    bash open-file.sh


    it will launch TeXStudio with the desired file loaded in the desired target location. I still can't just double-click open-file.sh on my desktop, since that will open my text editor, letting me edit the bash script. I want to double-click the open-file.sh script file and have TeXStudio open up my file.tex file.



    ### EDIT 3



    From this question, I deduct that I have done everything right and the file should be clickable and be executed upon clicking. Unfortunately, it doesn't. I think my permissions are correct, afaik



    enter image description here



    and same here



    -rwxr-xr-x me me 94 Apr 27 12:00 open-file






    share|improve this question
























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      Sorry for the tags. I don't know whih one applies. Please remove not pertaining ones, then delete this line. Or comment, and I'll do it myself.



      Background



      I want to put a link to a file located in /home/myname/some/path/file.tex on my desktop. This TeX file calls other TeX files inside it. Now, when I open the link, which is located on the desktop, my TeX editor, it says I opened the file /home/myname/Desktop/file.tex. I can't compile this file, because the other TeX files the main TeX file relies upon are not located where the program expects them.



      Main question



      How can I make a link file open the target file in its actual location instead of on the desktop?



      EDIT



      The solution advertised here does not work as intended. With



      #!/bin/bash
      exec /home/myname/some/path/file.tex "$@"


      I get



      /tmp/geany_run_script_JVX1HZ.sh: 7: /tmp/geany_run_script_JVX1HZ.sh: ./open-file.sh: Permission denied


      —----------------
      (program exited with code: 126)
      Press return to continue


      Where open-file.sh is the wrapper script located on my desktop.



      EDIT 2



      Although, if I open a terminal and do



      chmod a+x ./open-file.sh


      and change exec to texstudio, which incidentally is the program I use to open .tex files, then I can open a terminal and do



      bash open-file.sh


      it will launch TeXStudio with the desired file loaded in the desired target location. I still can't just double-click open-file.sh on my desktop, since that will open my text editor, letting me edit the bash script. I want to double-click the open-file.sh script file and have TeXStudio open up my file.tex file.



      ### EDIT 3



      From this question, I deduct that I have done everything right and the file should be clickable and be executed upon clicking. Unfortunately, it doesn't. I think my permissions are correct, afaik



      enter image description here



      and same here



      -rwxr-xr-x me me 94 Apr 27 12:00 open-file






      share|improve this question














      Sorry for the tags. I don't know whih one applies. Please remove not pertaining ones, then delete this line. Or comment, and I'll do it myself.



      Background



      I want to put a link to a file located in /home/myname/some/path/file.tex on my desktop. This TeX file calls other TeX files inside it. Now, when I open the link, which is located on the desktop, my TeX editor, it says I opened the file /home/myname/Desktop/file.tex. I can't compile this file, because the other TeX files the main TeX file relies upon are not located where the program expects them.



      Main question



      How can I make a link file open the target file in its actual location instead of on the desktop?



      EDIT



      The solution advertised here does not work as intended. With



      #!/bin/bash
      exec /home/myname/some/path/file.tex "$@"


      I get



      /tmp/geany_run_script_JVX1HZ.sh: 7: /tmp/geany_run_script_JVX1HZ.sh: ./open-file.sh: Permission denied


      —----------------
      (program exited with code: 126)
      Press return to continue


      Where open-file.sh is the wrapper script located on my desktop.



      EDIT 2



      Although, if I open a terminal and do



      chmod a+x ./open-file.sh


      and change exec to texstudio, which incidentally is the program I use to open .tex files, then I can open a terminal and do



      bash open-file.sh


      it will launch TeXStudio with the desired file loaded in the desired target location. I still can't just double-click open-file.sh on my desktop, since that will open my text editor, letting me edit the bash script. I want to double-click the open-file.sh script file and have TeXStudio open up my file.tex file.



      ### EDIT 3



      From this question, I deduct that I have done everything right and the file should be clickable and be executed upon clicking. Unfortunately, it doesn't. I think my permissions are correct, afaik



      enter image description here



      and same here



      -rwxr-xr-x me me 94 Apr 27 12:00 open-file








      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 27 at 18:46

























      asked Apr 26 at 16:30









      thymaro

      13617




      13617




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          I don't know how to make a link itself work like this, but there's a relatively easy way to get it done.



          The problem appears to be that program invoked to process your data is not running with its working directory set to the location of your data file.



          Instead of linking the file itself, write a launcher script and pass your file location to it as a parameter. Then, link to the script from your desktop entry.



          At least in KDE, this is easier to do by adding an entry to your Application Launcher with all the parameters set the way you want them and then dragging the entry from the menu to the desktop. It has a bunch of placeholder variables that let you modify the command and even lets you specify the working directory to use.



          This could be simple or fancy. Start with simple:



          #!/bin/bash
          ## Usage: launcheroo working-directory data-file
          ## defending this script is left as an exercise for the reader
          ## ... or you can ask in the comments ;)
          cd "$1"
          myprog "$2" ## or your more fancy exec that will figure out
          ## what program to run by itself


          invoked as:



          launcheroo path-to-data-files data-file


          This handles the most basic usage, and illustrates the approach, but doesn't handle any errors like bad or missing parameters



          To get a little fancier, you could extract the path from the specified data file path using dirname or bash parameter editing instead of passing it as a separate parameter.



          A quick and dirty way to get this done - especially for testing how it works - would be to just edit the desktop icon to run



          cd where-the-files-are ; exec ...


          Since this is Linux, there are probably many other ways to do this as well.



          If you add the file as an icon on the desktop, you can directly edit its .desktop file and get it to do all sorts of interesting things. I haven't done much with those.



          Just saw this answer which is essentially the same as mine with a slightly different spin to it.






          share|improve this answer






















          • A faint idea in the style of "and get it to do all sorts of interesting things" is what got me to start using linux in the first place, but as I'm not a programmer and find it hard to get into the matter without a direct tutor, since I have a day job I try to do to the best of my abilities, it's very hard for me to get the machines do my bidding. Thanks for the answer, I'll look into it.
            – thymaro
            May 3 at 11:43










          • Everyone has different skills and priorities.That's what makes the world work. I'd be happy to do a step by step on this, but it should probably be done outside of the Q&A here. I don't know how to get from here to there without publishing my personal email address, etc. I'll see what they say on meta.
            – Joe
            May 3 at 21:35










          • uhm... you can hit me up on telegram, github or twitter. I use the same handle on those three as on the SE network. are such comments allowed, when not explicitly posting the respective links?
            – thymaro
            May 4 at 7:30










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1028474%2fmake-link-open-target-file-not-file-at-link-location%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          I don't know how to make a link itself work like this, but there's a relatively easy way to get it done.



          The problem appears to be that program invoked to process your data is not running with its working directory set to the location of your data file.



          Instead of linking the file itself, write a launcher script and pass your file location to it as a parameter. Then, link to the script from your desktop entry.



          At least in KDE, this is easier to do by adding an entry to your Application Launcher with all the parameters set the way you want them and then dragging the entry from the menu to the desktop. It has a bunch of placeholder variables that let you modify the command and even lets you specify the working directory to use.



          This could be simple or fancy. Start with simple:



          #!/bin/bash
          ## Usage: launcheroo working-directory data-file
          ## defending this script is left as an exercise for the reader
          ## ... or you can ask in the comments ;)
          cd "$1"
          myprog "$2" ## or your more fancy exec that will figure out
          ## what program to run by itself


          invoked as:



          launcheroo path-to-data-files data-file


          This handles the most basic usage, and illustrates the approach, but doesn't handle any errors like bad or missing parameters



          To get a little fancier, you could extract the path from the specified data file path using dirname or bash parameter editing instead of passing it as a separate parameter.



          A quick and dirty way to get this done - especially for testing how it works - would be to just edit the desktop icon to run



          cd where-the-files-are ; exec ...


          Since this is Linux, there are probably many other ways to do this as well.



          If you add the file as an icon on the desktop, you can directly edit its .desktop file and get it to do all sorts of interesting things. I haven't done much with those.



          Just saw this answer which is essentially the same as mine with a slightly different spin to it.






          share|improve this answer






















          • A faint idea in the style of "and get it to do all sorts of interesting things" is what got me to start using linux in the first place, but as I'm not a programmer and find it hard to get into the matter without a direct tutor, since I have a day job I try to do to the best of my abilities, it's very hard for me to get the machines do my bidding. Thanks for the answer, I'll look into it.
            – thymaro
            May 3 at 11:43










          • Everyone has different skills and priorities.That's what makes the world work. I'd be happy to do a step by step on this, but it should probably be done outside of the Q&A here. I don't know how to get from here to there without publishing my personal email address, etc. I'll see what they say on meta.
            – Joe
            May 3 at 21:35










          • uhm... you can hit me up on telegram, github or twitter. I use the same handle on those three as on the SE network. are such comments allowed, when not explicitly posting the respective links?
            – thymaro
            May 4 at 7:30














          up vote
          0
          down vote













          I don't know how to make a link itself work like this, but there's a relatively easy way to get it done.



          The problem appears to be that program invoked to process your data is not running with its working directory set to the location of your data file.



          Instead of linking the file itself, write a launcher script and pass your file location to it as a parameter. Then, link to the script from your desktop entry.



          At least in KDE, this is easier to do by adding an entry to your Application Launcher with all the parameters set the way you want them and then dragging the entry from the menu to the desktop. It has a bunch of placeholder variables that let you modify the command and even lets you specify the working directory to use.



          This could be simple or fancy. Start with simple:



          #!/bin/bash
          ## Usage: launcheroo working-directory data-file
          ## defending this script is left as an exercise for the reader
          ## ... or you can ask in the comments ;)
          cd "$1"
          myprog "$2" ## or your more fancy exec that will figure out
          ## what program to run by itself


          invoked as:



          launcheroo path-to-data-files data-file


          This handles the most basic usage, and illustrates the approach, but doesn't handle any errors like bad or missing parameters



          To get a little fancier, you could extract the path from the specified data file path using dirname or bash parameter editing instead of passing it as a separate parameter.



          A quick and dirty way to get this done - especially for testing how it works - would be to just edit the desktop icon to run



          cd where-the-files-are ; exec ...


          Since this is Linux, there are probably many other ways to do this as well.



          If you add the file as an icon on the desktop, you can directly edit its .desktop file and get it to do all sorts of interesting things. I haven't done much with those.



          Just saw this answer which is essentially the same as mine with a slightly different spin to it.






          share|improve this answer






















          • A faint idea in the style of "and get it to do all sorts of interesting things" is what got me to start using linux in the first place, but as I'm not a programmer and find it hard to get into the matter without a direct tutor, since I have a day job I try to do to the best of my abilities, it's very hard for me to get the machines do my bidding. Thanks for the answer, I'll look into it.
            – thymaro
            May 3 at 11:43










          • Everyone has different skills and priorities.That's what makes the world work. I'd be happy to do a step by step on this, but it should probably be done outside of the Q&A here. I don't know how to get from here to there without publishing my personal email address, etc. I'll see what they say on meta.
            – Joe
            May 3 at 21:35










          • uhm... you can hit me up on telegram, github or twitter. I use the same handle on those three as on the SE network. are such comments allowed, when not explicitly posting the respective links?
            – thymaro
            May 4 at 7:30












          up vote
          0
          down vote










          up vote
          0
          down vote









          I don't know how to make a link itself work like this, but there's a relatively easy way to get it done.



          The problem appears to be that program invoked to process your data is not running with its working directory set to the location of your data file.



          Instead of linking the file itself, write a launcher script and pass your file location to it as a parameter. Then, link to the script from your desktop entry.



          At least in KDE, this is easier to do by adding an entry to your Application Launcher with all the parameters set the way you want them and then dragging the entry from the menu to the desktop. It has a bunch of placeholder variables that let you modify the command and even lets you specify the working directory to use.



          This could be simple or fancy. Start with simple:



          #!/bin/bash
          ## Usage: launcheroo working-directory data-file
          ## defending this script is left as an exercise for the reader
          ## ... or you can ask in the comments ;)
          cd "$1"
          myprog "$2" ## or your more fancy exec that will figure out
          ## what program to run by itself


          invoked as:



          launcheroo path-to-data-files data-file


          This handles the most basic usage, and illustrates the approach, but doesn't handle any errors like bad or missing parameters



          To get a little fancier, you could extract the path from the specified data file path using dirname or bash parameter editing instead of passing it as a separate parameter.



          A quick and dirty way to get this done - especially for testing how it works - would be to just edit the desktop icon to run



          cd where-the-files-are ; exec ...


          Since this is Linux, there are probably many other ways to do this as well.



          If you add the file as an icon on the desktop, you can directly edit its .desktop file and get it to do all sorts of interesting things. I haven't done much with those.



          Just saw this answer which is essentially the same as mine with a slightly different spin to it.






          share|improve this answer














          I don't know how to make a link itself work like this, but there's a relatively easy way to get it done.



          The problem appears to be that program invoked to process your data is not running with its working directory set to the location of your data file.



          Instead of linking the file itself, write a launcher script and pass your file location to it as a parameter. Then, link to the script from your desktop entry.



          At least in KDE, this is easier to do by adding an entry to your Application Launcher with all the parameters set the way you want them and then dragging the entry from the menu to the desktop. It has a bunch of placeholder variables that let you modify the command and even lets you specify the working directory to use.



          This could be simple or fancy. Start with simple:



          #!/bin/bash
          ## Usage: launcheroo working-directory data-file
          ## defending this script is left as an exercise for the reader
          ## ... or you can ask in the comments ;)
          cd "$1"
          myprog "$2" ## or your more fancy exec that will figure out
          ## what program to run by itself


          invoked as:



          launcheroo path-to-data-files data-file


          This handles the most basic usage, and illustrates the approach, but doesn't handle any errors like bad or missing parameters



          To get a little fancier, you could extract the path from the specified data file path using dirname or bash parameter editing instead of passing it as a separate parameter.



          A quick and dirty way to get this done - especially for testing how it works - would be to just edit the desktop icon to run



          cd where-the-files-are ; exec ...


          Since this is Linux, there are probably many other ways to do this as well.



          If you add the file as an icon on the desktop, you can directly edit its .desktop file and get it to do all sorts of interesting things. I haven't done much with those.



          Just saw this answer which is essentially the same as mine with a slightly different spin to it.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited May 3 at 8:26

























          answered May 3 at 8:18









          Joe

          1,161721




          1,161721











          • A faint idea in the style of "and get it to do all sorts of interesting things" is what got me to start using linux in the first place, but as I'm not a programmer and find it hard to get into the matter without a direct tutor, since I have a day job I try to do to the best of my abilities, it's very hard for me to get the machines do my bidding. Thanks for the answer, I'll look into it.
            – thymaro
            May 3 at 11:43










          • Everyone has different skills and priorities.That's what makes the world work. I'd be happy to do a step by step on this, but it should probably be done outside of the Q&A here. I don't know how to get from here to there without publishing my personal email address, etc. I'll see what they say on meta.
            – Joe
            May 3 at 21:35










          • uhm... you can hit me up on telegram, github or twitter. I use the same handle on those three as on the SE network. are such comments allowed, when not explicitly posting the respective links?
            – thymaro
            May 4 at 7:30
















          • A faint idea in the style of "and get it to do all sorts of interesting things" is what got me to start using linux in the first place, but as I'm not a programmer and find it hard to get into the matter without a direct tutor, since I have a day job I try to do to the best of my abilities, it's very hard for me to get the machines do my bidding. Thanks for the answer, I'll look into it.
            – thymaro
            May 3 at 11:43










          • Everyone has different skills and priorities.That's what makes the world work. I'd be happy to do a step by step on this, but it should probably be done outside of the Q&A here. I don't know how to get from here to there without publishing my personal email address, etc. I'll see what they say on meta.
            – Joe
            May 3 at 21:35










          • uhm... you can hit me up on telegram, github or twitter. I use the same handle on those three as on the SE network. are such comments allowed, when not explicitly posting the respective links?
            – thymaro
            May 4 at 7:30















          A faint idea in the style of "and get it to do all sorts of interesting things" is what got me to start using linux in the first place, but as I'm not a programmer and find it hard to get into the matter without a direct tutor, since I have a day job I try to do to the best of my abilities, it's very hard for me to get the machines do my bidding. Thanks for the answer, I'll look into it.
          – thymaro
          May 3 at 11:43




          A faint idea in the style of "and get it to do all sorts of interesting things" is what got me to start using linux in the first place, but as I'm not a programmer and find it hard to get into the matter without a direct tutor, since I have a day job I try to do to the best of my abilities, it's very hard for me to get the machines do my bidding. Thanks for the answer, I'll look into it.
          – thymaro
          May 3 at 11:43












          Everyone has different skills and priorities.That's what makes the world work. I'd be happy to do a step by step on this, but it should probably be done outside of the Q&A here. I don't know how to get from here to there without publishing my personal email address, etc. I'll see what they say on meta.
          – Joe
          May 3 at 21:35




          Everyone has different skills and priorities.That's what makes the world work. I'd be happy to do a step by step on this, but it should probably be done outside of the Q&A here. I don't know how to get from here to there without publishing my personal email address, etc. I'll see what they say on meta.
          – Joe
          May 3 at 21:35












          uhm... you can hit me up on telegram, github or twitter. I use the same handle on those three as on the SE network. are such comments allowed, when not explicitly posting the respective links?
          – thymaro
          May 4 at 7:30




          uhm... you can hit me up on telegram, github or twitter. I use the same handle on those three as on the SE network. are such comments allowed, when not explicitly posting the respective links?
          – thymaro
          May 4 at 7:30

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1028474%2fmake-link-open-target-file-not-file-at-link-location%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          pylint3 and pip3 broken

          Missing snmpget and snmpwalk

          How to enroll fingerprints to Ubuntu 17.10 with VFS491