Development > Scripting and Bash

ls /dev

<< < (3/4) > >>

Moltke:
Glad to help @bitsnpcs


--- Quote ---What I was curious about, my motivation, was how a GUI only displays the most recently mounted storage device, as the output option field, or how to make a GUI do this and if I could use this command ls /dev/sd* by attaching it to a button in a GUI to achieve similar type of result.
--- End quote ---

Hmmm...I think you could achieve that in python. Are you trying to create/creating a GUI for some specific purpose? May I suggest this program: http://page.sourceforge.net/  I've been playing around with it since last August. It teaches you how to create GUIs using python. From it's website: "PAGE is a cross-platform drag-and-drop GUI generator, bearing a resemblance to Visual Basic. It allows one to easily create GUI windows containing a selection of Tk and ttk widgets. Required are Tcl/Tk 8.6 and Python 2.7+.  PAGE springs from Virtual Tcl, a Tcl/Tk program, forked to generate Python modules that realizes the desired GUI. Tcl is required for running PAGE but is not required for executing the generated Python code." It's not perfect though, I found a bug while using it and reported to it's developer. It seems that the created GUIs won't show properly under python 3.6 - some buttons aren't visible -  wich is the one installed in my system, I had to install python2 so it works as expected. Also, since I've read you're learning python - and so am I by the way  ;D - you might find insteresting this too: https://thonny.org/ it's a "python IDE for begginers" as advertised on its website. Both programs are really light on resources and download sizes are really low, less than 5mb both I think. Page runs as a script so there's no need to install anything. Instructions for installing Thonny are on the link above.

Hope you find this info helpful! :)

bitsnpcs:

--- Quote from: Moltke on September 22, 2018, 07:51:34 AM ---I'm not sure what you're trying to do, but it seems that you want to ls into a usb stick?
Hope this helps! :)

--- End quote ---
@Moltke thank you  :) I have read the info on the link you gave me, it was helpful.

The answer by @supergamer is what I needed to know, I cannot mark things solved in this section of forum.

I am not trying to do something at this stage, just experimenting.

What I was curious about, my motivation, was how a GUI only displays the most recently mounted storage device, as the output option field, or how to make a GUI do this.
and
if I could use this command ls /dev/sd* by attaching it to a button in a GUI to achieve similar type of result.

I understand from @supergamer explanation why this did not work in the way I expected, and I also learned some new and useful information on the structure and use from you both. :)

Moltke:

--- Quote ---As you can see I ran the code , I then inserted a USB stick and used up arrow on keyboard to reuse the same code and run it again, thus allowing for a comparison of before and after adding the USB stick.
It produced 2 new results the /dev/sdb and the /dev/sdb1 rather than the 1 new result I was expecting, why is this ?
--- End quote ---

@bitsnpcs  I'm not sure what you're trying to do, but it seems that you want to ls into a usb stick? if so, then I think the correct path would be run/media/bitsnpcs, like so:
--- Code: ---$ ls /run/media/bitsnpcs
--- End code ---
and then your usb stick should appear in the list just like mine - MOK - does as you can see in the image bellow. 



You might want to read here: http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/dev.html

Hope this helps! :)

bitsnpcs:
Thank You @supergamer  :) for explaining .


supergamer:

--- Quote ---As you can see I ran the code , I then inserted a USB stick and used up arrow on keyboard to reuse the same code and run it again, thus allowing for a comparison of before and after adding the USB stick.It produced 2 new results the /dev/sdb and the /dev/sdb1 rather than the 1 new result I was expecting, why is this ?
--- End quote ---



My understanding on why the 2 new devices might be rudimentary but it is how I keep things straight.


In the /dev folder it shows the devices as well as the partitions (partitions being treated as a devices also). So you see the /dev/sda (device) and the /dev/sda1 (partition) as well as the new devices like the new usb device which is /dev/sdb (device) and the partition /dev/sdb1 (partition)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version