TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: ALL
from: DENNIS LEE BIEBER
date: 2019-11-05 21:33:00
subject: Re: file -i vs xdg-mime q

On Tue, 5 Nov 2019 10:03:11 +0100, "R.Wieser" 
declaimed the following:

>
>Houston, we have a problem :  I just stuck another SD card into the Pi (one
>with which I did not anything with than a first-time boot and having it
>install raspbian in offline mode).   I create a "test.py" file with just a
>shebang line mentioning "python3".    Here xdg-mime did return a
>"text/x-python3" for it ...
>
>In other words, while either your possibility or just me having unwittingly
>altered more than intended sound plausible, it does seem to point to our
>versions of the OS not being the same ...
>

 Interesting... I pulled down the 3.2.1 NOOBS file on October 1, and
probably spent October 2 installing it on both 3B+, the 2GB 4B, and 4GB 4B.

 One 3B+ is kept on my desk, next to a Beaglebone Black -- primarily for
doing testing and investigations for answering questions here (and the
Beaglebone forum). Typically, whenever I boot one, I run apt-get
update/upgrade cycle.

pi@rpi3bplus-1:~$ date
Tue 05 Nov 2019 09:01:02 PM EST
pi@rpi3bplus-1:~$ uname -a
Linux rpi3bplus-1 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l
GNU/Linux
pi@rpi3bplus-1:~$ file *
Desktop:          directory
Documents:        directory
Downloads:        directory
MagPi:            directory
Music:            directory
Pictures:         directory
Public:           directory
RPi-config.sh:    POSIX shell script, ASCII text executable
Templates:        directory
test1.py:         Python script, ASCII text executable
test1.py.desktop: ASCII text
test2.py:         Python script, ASCII text executable
tst-js.svg:       XML 1.0 document text
tst-nojs.svg:     XML 1.0 document text
tst.png:          PNG image data, 800 x 600, 8-bit/color RGB,
non-interlaced
tst.py:           ASCII text
tst.svg:          XML 1.0 document text
Videos:           directory
pi@rpi3bplus-1:~$ file -i *
Desktop:          inode/directory; charset=binary
Documents:        inode/directory; charset=binary
Downloads:        inode/directory; charset=binary
MagPi:            inode/directory; charset=binary
Music:            inode/directory; charset=binary
Pictures:         inode/directory; charset=binary
Public:           inode/directory; charset=binary
RPi-config.sh:    text/x-shellscript; charset=us-ascii
Templates:        inode/directory; charset=binary
test1.py:         text/x-python; charset=us-ascii
test1.py.desktop: text/plain; charset=us-ascii
test2.py:         text/x-python; charset=us-ascii
tst-js.svg:       text/xml; charset=utf-8
tst-nojs.svg:     text/xml; charset=utf-8
tst.png:          image/png; charset=binary
tst.py:           text/plain; charset=us-ascii
tst.svg:          text/xml; charset=utf-8
Videos:           inode/directory; charset=binary
pi@rpi3bplus-1:~$ ls
Desktop    MagPi     Public         test1.py          tst-js.svg    tst.py
Documents  Music     RPi-config.sh  test1.py.desktop  tst-nojs.svg  tst.svg
Downloads  Pictures  Templates      test2.py          tst.png       Videos
pi@rpi3bplus-1:~$

 Even more perplexing... tst.py doesn't even ID as a Python script!

pi@rpi3bplus-1:~$ diff test1.py test2.py
0a1
> #!/usr/bin/env python3
2c3
<     generic Python script with no shebang line
---
>     generic Python script with shebang line
9c10
<     input("return to exit")
---
>
pi@rpi3bplus-1:~$

While test2.py has python3 in the shebang line. Hmm, wonder what happens if
I don't use the environment search... stand by... Nope: /usr/bin/python3
still results in plain x-python.

 Just sftp'd the files from R-Pi to BBB... (BBB is still on Debian
Stretch -- I think Buster is still in the Beta builds for Beagle).

debian@beaglebone:~$ date
Tue Nov  5 21:09:04 EST 2019
debian@beaglebone:~$ uname -a
Linux beaglebone 4.14.108-ti-r113 #1 SMP PREEMPT Wed Jul 31 00:01:10 UTC
2019 armv7l GNU/Linux
debian@beaglebone:~$ ls
bin  hw  hw.adb  hw.ali  hw.o  jnk.py  test1.py  test2.py  tst.py
debian@beaglebone:~$ file *
bin:      directory
hw:       ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV),
dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux
3.2.0, BuildID[sha1]=8c4fc0c2238064834a37b8db0339d88c834eb91a, not stripped
hw.adb:   ASCII text
hw.ali:   ASCII text
hw.o:     ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not
stripped
jnk.py:   ASCII text
test1.py: Python script, ASCII text executable
test2.py: Python script, ASCII text executable
tst.py:   ASCII text
debian@beaglebone:~$ file -i *
bin:      inode/directory; charset=binary
hw:       application/x-sharedlib; charset=binary
hw.adb:   text/plain; charset=us-ascii
hw.ali:   text/plain; charset=us-ascii
hw.o:     application/x-object; charset=binary
jnk.py:   text/plain; charset=us-ascii
test1.py: text/plain; charset=us-ascii
test2.py: text/x-python; charset=us-ascii
tst.py:   text/plain; charset=us-ascii
debian@beaglebone:~$


This machine only identified the one with /usr/bin/python3 as x-python,
even though both test1 and test2 are also flagged as executable.



>> Created a similar file (couldn't find a simple way to do that from the
>> GUI -- had to use text editor).
>
>On my desktop I can rightclick -> create new -> empty file.    After which I
>ofcourse still have to open it with a text editor to add the shebang line
>though ...
>

 I'd meant the launcher (.desktop) file -- some desktop managers have a
create launcher right-click menu entry that provides fields for the
critical items. For the case referenced, I had to manually type the
contents of a .desktop file based on what was shown on another machine.

>>  Then found I had to install xterm -- seems the "launch in terminal"
>> doesn't find the R-Pi terminal
>
>And that does seem to confirm we're not running the same OS ...   When I do
>that the script is ran in something called "lxterminal"
>("psutil.Process().parent().name()")
>

 Weird... my normal R-Pi terminal IS LXTerminal, but starting an
executable script (test2.py, with shebang) by double-clicking from the file
manager gives that

 [execute] [execute in terminal] [open] [cancel]

window, and [execute in terminal] opens xterm.

 Even stranger... test1.py -- with NO shebang, but chmod +x, when double
clicked, opens in the Thonny IDE! No request to execute it.


--
 Wulfraed                 Dennis Lee Bieber         AF6VN
 wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.