Hello Guest, if you are reading this it means you have not registered yet. Please take a second, Click here to register, and in a few simple steps you will be able to enjoy our community and use our OpenViX support section.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: wget from github works on command line but failes when called as .sh

  1. #1

    Title
    Member
    Join Date
    Mar 2016
    Posts
    38
    Thanks
    5
    Thanked 1 Time in 1 Post

    wget from github works on command line but failes when called as .sh

    I have a line of code which is downloading a file from my github. When I test this from command line it works as expected, but when I call this from a .sh from inside my plugin I get the following error

    Code:
    wget: error getting response: reset by peer.
    I call the script like this:

    /bin/busybox ash ./tmp/getfiles.sh

    if I run the same script from command line it works. Can anyone shed any light? Is my script being called differently when being called from the plugin from a command line?

    Thanks in advance

  2. #2
    Huevos's Avatar
    Title
    Administrator
    Join Date
    Jun 2010
    Location
    38.5N, 0.5W
    Posts
    13,614
    Thanks
    2,006
    Thanked 4,947 Times in 3,269 Posts
    If it is a plugin why are you using wget? Why aren't you using python built in methods?
    Help keep OpenViX servers online.Please donate!

  3. #3

    Title
    Member
    Join Date
    Mar 2016
    Posts
    38
    Thanks
    5
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Huevos View Post
    If it is a plugin why are you using wget? Why aren't you using python built in methods?
    Most likely as I'm learning as I go along, I'm certainly no master with python, but when I've tested python commands equivalent to wget I don't see a progress bar or anything similar (which from a user experience can appear to be that nothing is happening, depending on the download size), I'm running a sub-routine in the plugin which uses a combination of python and shell script; i've found myself use os. and os.system so frequently in python, that it's just easier for me to drop to a script to do it. But if you can suggest a way I could perhaps do this, I'll happily give it a try.

  4. #4
    birdman's Avatar
    Title
    Moderator
    Join Date
    Sep 2014
    Location
    Hitchin, UK
    Posts
    7,777
    Thanks
    237
    Thanked 1,658 Times in 1,306 Posts
    Quote Originally Posted by Daviemck View Post
    Most likely as I'm learning as I go along, I'm certainly no master with python, but when I've tested python commands equivalent to wget I don't see a progress bar or anything similar (which from a user experience can appear to be that nothing is happening, depending on the download size),
    So you're expecting stdout/stderr from a subprocess to get displayed on the screen? Does it??

    I call the script like this:

    /bin/busybox ash ./tmp/getfiles.sh
    Don't.
    The first line should be:
    Code:
    #!/bin/sh
    and the file should have its execute bits set. Then just run:
    Code:
    /tmp/getfiles.sh
    However, you do have to consider where stdin, stdout and stderr are. When run from the command line they are all your tty. When run from enigma2 they are not. stdout and stderr are (IIRC) running to the debug log (if the user has one). stdin will run from /dev/console (as will stdout and stderr with no debug log). This is probably not what you want.
    MiracleBox Prem Twin HD - 2@DVB-T2 + Xtrend et8000 - 5(incl. 2 different USBs)@DVB-T2[terrestrial - UK Freeview HD, Sandy Heath] - LAN/USB-stick/HDD

  5. #5
    Huevos's Avatar
    Title
    Administrator
    Join Date
    Jun 2010
    Location
    38.5N, 0.5W
    Posts
    13,614
    Thanks
    2,006
    Thanked 4,947 Times in 3,269 Posts
    Should be using urllib.

    Also, you can push anything to the display as you go along. E2 has a built in progress bar. You just need to call it from your plugin.
    Last edited by Huevos; 07-08-16 at 18:18.
    Help keep OpenViX servers online.Please donate!

  6. #6

    Title
    Member
    Join Date
    Mar 2016
    Posts
    38
    Thanks
    5
    Thanked 1 Time in 1 Post
    Quote Originally Posted by birdman View Post
    So you're expecting stdout/stderr from a subprocess to get displayed on the screen? Does it??
    I'm not sure what those are, but when you call the code as I have you see a command line window and every output to screen that you would see had you run it from the command line - Don't ask me how, I've just looked through how others have achieved this and worked with it.

    Quote Originally Posted by birdman View Post
    The first line should be:
    Code:
    #!/bin/sh
    and the file should have its execute bits set. Then just run:
    Code:
    /tmp/getfiles.sh
    I think you are confusing the code of the .sh file (which has that in it) to how I'm calling it from within python - I only quoted one line from the .sh file, not the entire file. The rest of the .sh script runs fine of which there are over 100 lines, it's just this one line that's being problematic

    However, you do have to consider where stdin, stdout and stderr are. When run from the command line they are all your tty. When run from enigma2 they are not. stdout and stderr are (IIRC) running to the debug log (if the user has one). stdin will run from /dev/console (as will stdout and stderr with no debug log). This is probably not what you want.
    OK, WAY too confusing, if there is not an easy answer to this perhaps I'll find another way. If I had to guess I'd say that when executed from within the plugin, the .sh is being executed with different privileges or different access

  7. #7

    Title
    Member
    Join Date
    Mar 2016
    Posts
    38
    Thanks
    5
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Huevos View Post
    Should be using urllib.

    Also, you can push anything to the display as you go along. E2 has a built in progress bar. You just need to call it from your plugin.
    OK Thanks, I can look up reference to urllib, but in the absence of a reference guide to E2, where do I found out more about how to call a progress bar?

  8. #8
    birdman's Avatar
    Title
    Moderator
    Join Date
    Sep 2014
    Location
    Hitchin, UK
    Posts
    7,777
    Thanks
    237
    Thanked 1,658 Times in 1,306 Posts
    Quote Originally Posted by Daviemck View Post
    I'm not sure what those are, but when you call the code as I have you see a command line window and every output to screen that you would see had you run it from the command line - Don't ask me how, I've just looked through how others have achieved this and worked with it.
    Do you have a debug log enabled? If not, enable one and test what happens next.

    I think you are confusing the code of the .sh file (which has that in it) to how I'm calling it from within python - I only quoted one line from the .sh file, not the entire file.
    OK, then just make it executable and execute it. You've already told the script which handler to use.

    ...perhaps I'll find another way.
    As had been noted, using urllib directly within python would be better.

    If I had to guess I'd say that when executed from within the plugin, the .sh is being executed with different privileges or different access
    No. In both cases it will be run by root (well, it certainly will if run from enigma2).

    Also note that the error message indicates that that the connexion is being cleared at the server (remote) end.
    So, have you looked at your github server logs to see why it is chopping the connexion?

    Or perhaps you could post the script (as a zip file?
    MiracleBox Prem Twin HD - 2@DVB-T2 + Xtrend et8000 - 5(incl. 2 different USBs)@DVB-T2[terrestrial - UK Freeview HD, Sandy Heath] - LAN/USB-stick/HDD

  9. #9
    Huevos's Avatar
    Title
    Administrator
    Join Date
    Jun 2010
    Location
    38.5N, 0.5W
    Posts
    13,614
    Thanks
    2,006
    Thanked 4,947 Times in 3,269 Posts
    You're not going to find tutorials on this stuff anywhere. You need to look at code in E2 to figure it out. Have a look in screens/servicescan.py for an example of progress bar.

    for an example of urllib look in ABM updateproviders.py or yweather plugin.

    Sorry I can't post a link from this device.
    Help keep OpenViX servers online.Please donate!

  10. #10
    Rob van der Does's Avatar
    Title
    ViX Beta Tester
    Join Date
    Apr 2010
    Location
    The Netherlands & France
    Posts
    36,261
    Thanks
    1,720
    Thanked 9,461 Times in 6,675 Posts
    Quote Originally Posted by Daviemck View Post
    I have a line of code which is downloading a file from my github. When I test this from command line it works as expected, but when I call this from a .sh from inside my plugin I get the following error

    Code:
    wget: error getting response: reset by peer.
    I call the script like this:

    /bin/busybox ash ./tmp/getfiles.sh

    if I run the same script from command line it works. Can anyone shed any light? Is my script being called differently when being called from the plugin from a command line?
    Have a look at the attached plugin: it has a build in updater (in the plugin folder), which does something along the lines as you're trying (if I understood you correctly).
    Attached Files Attached Files

    Help asked via PM will be ignored.
    The forum is there for help and all will benefit from your questions.
    NO CARD SHARING TALK WILL BE TOLERATED, LAN OR WAN, IN OPEN FORUM OR PM !

    English is not my native tongue.
    I apologise for all my grammar, spelling and idiom errors.

  11. #11

    Title
    Member
    Join Date
    Mar 2016
    Posts
    38
    Thanks
    5
    Thanked 1 Time in 1 Post
    I'm just going to take a minute to reset this discussion.

    During early development I was storing the files to download on an internet based web server - Using, as I mention above, wget as part of a lengthy script that runs and everything works exactly as expect. The ONLY change I've made is moving the files I need to download to github (and obviously updating the location in the script) and now I get the error reset by peer. I did a quick bit of testing with urllib earlier today and that writes a file of 162k - I've explored the file and that is an http error 403 (forbidden) response. This is ONLY happening when executed from within a python environment. So the only thing I can ascertain from this is must be changing something like the user agent as it requests data.

    It was mentioned above that I should check the logs on github - I can't see anyway of doing that.

    Rob van der Does, I'll check out that plugin, thanks

  12. #12
    abu baniaz's Avatar
    Title
    Moderator
    Join Date
    Sep 2010
    Location
    East London
    Posts
    23,360
    Thanks
    6,441
    Thanked 9,160 Times in 6,235 Posts

    wget from github works on command line but f

    When Pembo wrote script to download ABM config file, it would not work with GitHub.



    When Huevos did so with Python, works fine.



    Sent from my XT1032 using Forum Fiend v1.3.3.

  13. #13
    Huevos's Avatar
    Title
    Administrator
    Join Date
    Jun 2010
    Location
    38.5N, 0.5W
    Posts
    13,614
    Thanks
    2,006
    Thanked 4,947 Times in 3,269 Posts
    Can you give us the URL to try.
    Help keep OpenViX servers online.Please donate!

  14. #14
    birdman's Avatar
    Title
    Moderator
    Join Date
    Sep 2014
    Location
    Hitchin, UK
    Posts
    7,777
    Thanks
    237
    Thanked 1,658 Times in 1,306 Posts
    Quote Originally Posted by Daviemck View Post
    I did a quick bit of testing with urllib earlier today and that writes a file of 162k - I've explored the file and that is an http error 403 (forbidden) response.
    162k for a 403 response?
    Was there any other useful info in that?

    This is ONLY happening when executed from within a python environment. So the only thing I can ascertain from this is must be changing something like the user agent as it requests data.
    Well, python's urllib isn't go to send the same UA as wget.
    But wget run from within python would, as it's still wget.

    It was mentioned above that I should check the logs on github - I can't see anyway of doing that.
    Probably not if it's on github - I though you might be running your own server.
    MiracleBox Prem Twin HD - 2@DVB-T2 + Xtrend et8000 - 5(incl. 2 different USBs)@DVB-T2[terrestrial - UK Freeview HD, Sandy Heath] - LAN/USB-stick/HDD

  15. #15
    dsayers's Avatar
    Title
    ViX Beta Tester
    Join Date
    Mar 2016
    Posts
    1,761
    Thanks
    473
    Thanked 607 Times in 433 Posts
    When downloading from github within python use raw i had similar issues.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.