|
Prev: Inquiries about Jesus Christ
Next: popen
From: Evenbit on 9 Jul 2008 19:53 Yes, I've discovered the nifty gcc 'popen' function which can be used from ASM to do stuff like this: ; nasm -f elf -o tellmore.o tellmore.asm ; gcc -o tellmore tellmore.o section .data cmd db 'more', 10, 0 mod db 'w', 0 fmt db '%d', 10, 0 section .bss cnt resd 1 fid resd 1 section .text global main extern popen extern pclose extern fprintf main: push mod push cmd call popen add esp, 8 mov [fid], eax mov ecx, 50 mov [cnt], ecx loop: push DWORD [cnt] push fmt push DWORD [fid] call fprintf add esp, 12 dec DWORD [cnt] jnz loop mov eax, [fid] push eax call pclose add esp, 4 xor eax, eax ret Okay, the reason I am playing with this ( I'm sure you were wondering ) is that I've been investigating the use of zenity (and other "interactive scripting widgets") from ASM. zenity is GUI and is default installed in Ubunty. An example of its use: Install surfraw, then run this: burnt.sh #!/bin/bash ELVI=$(zenity \ --list \ --title="ELVI" \ --text "Pick an elvi service:" \ --radiolist \ --column "Pick" \ --column "Elvi" \ TRUE "sourceforge" \ FALSE "freshmeat" \ FALSE "slashdot"); TEXT=$(zenity \ --entry \ --title="TERM" \ --text "Enter the search term?"); echo "" echo "searching" $ELVI "for" $TEXT surfraw $ELVI $TEXT And, no, you don't exactly have to be "burnt" to catch the irony. Also, long before zenity, there were dialog, Xdialog, etc... and all Debians have a smaller CUI thingy called whiptail. This ncurses-based thingy downloaded with a 2008 tag, but my tests show it isn't even Y2K compliant, amoung other things. http://invisible-island.net/dialog/ Anyway, I've learned how to get text input from zenity: ; nasm -f elf -o result.o result.asm ; gcc -o result result.o section .data cmd db 'zenity --entry', 10, 0 mod db 'r', 0 section .bss fid resd 1 buf resb 256 section .text global main extern popen extern pclose extern fgets extern printf main: push mod push cmd call popen add esp, 8 mov [fid], eax push DWORD [fid] push 256 push buf call fgets add esp, 12 push buf call printf add esp, 4 mov eax, [fid] push eax call pclose add esp, 4 xor eax, eax ret But, my question is, how does one go about obtaining a number value result?? $ zenity --question; echo $? Gives 0 if I click 'Okay' Gives 1 if I click 'Cancel' Nathan.
From: dickey on 10 Jul 2008 15:28 Evenbit wrote: > This ncurses-based thingy downloaded with a 2008 tag, but my tests > show it isn't even Y2K compliant, amoung other things. > http://invisible-island.net/dialog/ That could be referring to the calendar widget (which echoes a date in dd-mm-yyyy format), but since it works with dates before/after 2000, doesn't seem likely. Have you any specific comment? -- Thomas E. Dickey http://invisible-island.net ftp://invisible-island.net
From: Evenbit on 11 Jul 2008 01:46 On Jul 10, 3:28 pm, dickey <dic...(a)his.com> wrote: > Evenbit wrote: > > This ncurses-based thingy downloaded with a 2008 tag, but my tests > > show it isn't even Y2K compliant, amoung other things. > >http://invisible-island.net/dialog/ > > That could be referring to the calendar widget (which echoes a date in > dd-mm-yyyy format), > but since it works with dates before/after 2000, doesn't seem likely. > Have you any specific > comment? > Oh, you "hard-coded" the date into the script: #!/bin/sh # $Id: calendar,v 1.4 2003/10/09 22:45:06 tom Exp $ : ${DIALOG=dialog} exec 3>&1 USERDATE=`$DIALOG --title "CALENDAR" --calendar "Please choose a date..." 0 0 7 7 1981 2>&1 1>&3` code=$? exec 3>&- case $code in 0) echo "Date entered: $USERDATE.";; 1) echo "Cancel pressed.";; 255) echo "Box closed.";; esac Now do you see why someone (me) who ran this script on July 7, 2008 would get the impression that a Y2K bug might be the cause? Nathan.
From: dickey on 11 Jul 2008 07:29 On Jul 11, 1:46 am, Evenbit <nbaker2...(a)charter.net> wrote: > On Jul 10, 3:28 pm, dickey <dic...(a)his.com> wrote: > > > Evenbit wrote: > > > This ncurses-based thingy downloaded with a 2008 tag, but my tests > > > show it isn't even Y2K compliant, amoung other things. > > >http://invisible-island.net/dialog/ > > > That could be referring to the calendar widget (which echoes a date in > > dd-mm-yyyy format), > > but since it works with dates before/after 2000, doesn't seem likely. > > Have you any specific > > comment? > > Oh, you "hard-coded" the date into the script: > > #!/bin/sh > # $Id: calendar,v 1.4 2003/10/09 22:45:06 tom Exp $ > : ${DIALOG=dialog} > > exec 3>&1 > USERDATE=`$DIALOG --title "CALENDAR" --calendar "Please choose a > date..." 0 0 7 7 1981 2>&1 1>&3` I could have used the date command to generate values, but (a) didn't consider it, (b) might have decided it wasn't necessary to demonstrate the widget, and (c) chose a fixed date to make it simple to compare results. > Now do you see why someone (me) who ran this script on July 7, 2008 > would get the impression that a Y2K bug might be the cause? I might add an example for "current" date, but probably won't change the others...
From: Evenbit on 11 Jul 2008 14:07
On Jul 10, 2:28 am, Frank Kotler <fbkot...(a)verizon.net> wrote: > > Have you looked at Jeff Owens' "xhelper"?http://www.linuxasmtools.net > That built okay for me (Of course! It's in assembly!). I can't quite > figure out what that's "for", either. Just "xhelper" produces a "window > list", plus some other info. "xhelper -x" *says* "window list", but then > segfaults... I'll probably look at that more, before I get around to > "zenity". Supposed to be a script processor to manipulate windows from > the command line. I don't *think* it knows about "dialogs", so probably > not useful for... whatever it is you're trying to do... > Oh! I think I see what Jeff is up to. In AsmLibx he has the beginning of support for these zenity/whiptail/tk/etc.-style widget things. Perhaps his eventual goal will be to extend this into a GTK/ QT/etc.-style framework? Xhelper is a re-implementation of his 'DoMac' scripting language with a focus on the X protocol -- for both gathering information and to manage it. So, Xhelper is the "groundwork" for designing a Gnome/KDE/etc.-style window manager. Nathan. |