Discussion:
EXEC or SHELL can not READ WRITE simultaneously well with process?
(too old to reply)
Phạm Quang Dương
2010-08-15 20:09:46 UTC
Permalink
I have searched around with Google but still can not find an other problem
like mine.
My code below base on the Console example project of Gambas.
I want run a process like this:

PUBLIC $mainProcess AS Process

PUBLIC SUB Form_Open()

$mainProcess = SHELL "7z x /demo/file.7z -o/tmp" FOR READ WRITE '
Extract /demo/file.7z to /tmp folder, same problem with EXEC

END

Note that I have extracted this file to /tmp before, so 7z will ask
overwrite or not. And I want take control and answer from Gambas:

PUBLIC SUB Process_Read()

DIM sLine AS String

LINE INPUT #$mainProcess, sLine ' I used READ #$mainProcess, sLine, -256
too, but it break some line, and read multiple line in same moment
txtLog.Text &= sLine & gb.newline
IF InStr(sLine, "(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all
/ (Q)uit?") > 0 THEN
' A message.question here, then print an answer like this
PRINT #$mainProcess, "Q" ' Quit the process
ENDIF

END

Also I created a button to manually response to process:

PRIVATE SUB Button1_Click()

PRINT #$mainProcess, "Q"

END

Finally, to detect program working:

PUBLIC SUB Process_Kill()

Message.Info("Process terminated")

END

My problem is, if I use FOR READ WRITE, I can't get the process output until
process terminates (SUB Process_Read() seems not work - txtLog is blank).
When I click the Button1, the process terminates immediately, and now the
output appears in txtLog text box.
If I use FOR INPUT OUTPUT, I can get the output like I want - the output
appears in txtLog text box, (SUB Process_Read() work => PRINT "Quit" message
to process) but process not terminates, even when I click Button1.

An other small problem is from Gambas IDE. I use shortcut keys (Ctrl+C,
Ctrl+X) to copy, cut text from Gambas Editor (when cut, the selected text
disappears), but I can not paste anywhere, even back to Gambas editor. But I
use the context menu, it works fine.

My Gambas version is 2.20 (full is 2.20.2-1.fc13.i686) on Fedora 13. My
machiine is DELL Inspiron 1440 (Pen Dual Core).
Thank for answers. Sorry for my English.
Benoît Minisini
2010-08-15 20:18:52 UTC
Permalink
Post by Phạm Quang Dương
I have searched around with Google but still can not find an other problem
like mine.
My code below base on the Console example project of Gambas.
PUBLIC $mainProcess AS Process
PUBLIC SUB Form_Open()
$mainProcess = SHELL "7z x /demo/file.7z -o/tmp" FOR READ WRITE '
Extract /demo/file.7z to /tmp folder, same problem with EXEC
END
Note that I have extracted this file to /tmp before, so 7z will ask
PUBLIC SUB Process_Read()
DIM sLine AS String
LINE INPUT #$mainProcess, sLine ' I used READ #$mainProcess, sLine, -256
too, but it break some line, and read multiple line in same moment
txtLog.Text &= sLine & gb.newline
IF InStr(sLine, "(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all
/ (Q)uit?") > 0 THEN
' A message.question here, then print an answer like this
PRINT #$mainProcess, "Q" ' Quit the process
ENDIF
END
PRIVATE SUB Button1_Click()
PRINT #$mainProcess, "Q"
END
PUBLIC SUB Process_Kill()
Message.Info("Process terminated")
END
My problem is, if I use FOR READ WRITE, I can't get the process output
until process terminates (SUB Process_Read() seems not work - txtLog is
blank). When I click the Button1, the process terminates immediately, and
now the output appears in txtLog text box.
If I use FOR INPUT OUTPUT, I can get the output like I want - the output
appears in txtLog text box, (SUB Process_Read() work => PRINT "Quit"
message to process) but process not terminates, even when I click Button1.
You must not use 'LINE INPUT #Process, Var' to read a process output in
Process_Read. You must use 'READ #Process, Var, -MaxLength', add 'Var' to a
'Buffer', and extract lines from that 'Buffer'.

Without a full project to test, I cannot say more at the moment.

Note that Gambas 3 is more clever than Gambas 2 for that kind of situation.
Post by Phạm Quang Dương
An other small problem is from Gambas IDE. I use shortcut keys (Ctrl+C,
Ctrl+X) to copy, cut text from Gambas Editor (when cut, the selected text
disappears), but I can not paste anywhere, even back to Gambas editor. But
I use the context menu, it works fine.
CTRL+V works perfectly there. Do you have more details?
--
Benoît Minisini
Phạm Quang Dương
2010-08-17 18:58:59 UTC
Permalink
1. Thank you for your response, it works better now.

2.The problem of shortcuts keys Ctrl+C, Ctrl+X is: when I use those
shortcut keys, I can paste only to the Gambas project editor window from
where I copy (I can paste to different tabs). When I switch to other windows
e.g gedit or an other Gambas project window, there's nothing to paste. But
when return to the first Gambas project window, I still can paste. It's like
that the shortcut keys use a "local clipboard" not the clipboard of system.
But this problem doesn't happen with the context menu. (Paste here include
both Ctrl+V and menu).
Benoît Minisini
2010-08-23 15:03:43 UTC
Permalink
Post by Phạm Quang Dương
1. Thank you for your response, it works better now.
2.The problem of shortcuts keys Ctrl+C, Ctrl+X is: when I use those
shortcut keys, I can paste only to the Gambas project editor window from
where I copy (I can paste to different tabs). When I switch to other
windows e.g gedit or an other Gambas project window, there's nothing to
paste. But when return to the first Gambas project window, I still can
paste. It's like that the shortcut keys use a "local clipboard" not the
clipboard of system. But this problem doesn't happen with the context
menu. (Paste here include both Ctrl+V and menu).
Strange: it works perfectly as expected there. I copy some text with CTRL+C,
and I paste it in gedit with CTRL+V, and that works!

Regards,
--
Benoît Minisini
richard terry
2010-08-23 21:51:29 UTC
Permalink
Post by Benoît Minisini
Post by Phạm Quang Dương
1. Thank you for your response, it works better now.
2.The problem of shortcuts keys Ctrl+C, Ctrl+X is: when I use those
shortcut keys, I can paste only to the Gambas project editor window from
where I copy (I can paste to different tabs). When I switch to other
windows e.g gedit or an other Gambas project window, there's nothing to
paste. But when return to the first Gambas project window, I still can
paste. It's like that the shortcut keys use a "local clipboard" not the
clipboard of system. But this problem doesn't happen with the context
menu. (Paste here include both Ctrl+V and menu).
Strange: it works perfectly as expected there. I copy some text with
CTRL+C, and I paste it in gedit with CTRL+V, and that works!
Regards,
I've changed the topic header - but just to comment here, this is a long
standing and inconsistant problem I've noticed in the linux environment
gambas.

I has has happened more to more when I do ctrl C or use a menu with a copy
option, then switch immediately to gambas and do a Ctrl V or visa-versa.

On the occasions it dosn't work, either nothing pastes, or what pastes was
from some previous copy.

Can't reproduce it not common - but just repeating that it does exist. My two
linux distro's I've experienced this in as ARCH and KUbuntu.


Regards

Richard
Jussi Lahtinen
2010-08-24 16:22:19 UTC
Permalink
I have noticed it with Ubuntu also.
I use Parcellite clipboard manager, I'm not sure if it matters.
That bug is rare and I have not figured out how to reproduce it.

Jussi
Post by richard terry
Post by Benoît Minisini
Post by Phạm Quang Dương
1. Thank you for your response, it works better now.
2.The  problem of shortcuts keys Ctrl+C, Ctrl+X is: when I use those
shortcut keys, I can paste only to the Gambas project editor window from
where I copy (I can paste to different tabs). When I switch to other
windows e.g gedit or an other Gambas project window, there's nothing to
paste. But when return to the first Gambas project window, I still can
paste. It's like that the shortcut keys use a "local clipboard" not the
clipboard of system. But this problem doesn't happen with the context
menu. (Paste here include both Ctrl+V and menu).
Strange: it works perfectly as expected there. I copy some text with
 CTRL+C, and I paste it in gedit with CTRL+V, and that works!
Regards,
I've changed the topic header - but just to comment here, this is a long
standing and inconsistant problem I've noticed in the linux environment
gambas.
I has has happened more to more when I do ctrl C or use a menu with a copy
option, then switch immediately to gambas and do a Ctrl V or visa-versa.
On the occasions it dosn't work, either nothing pastes, or what pastes was
from some previous copy.
Can't reproduce it  not common - but just repeating that it does exist. My two
linux distro's I've experienced this in as ARCH and KUbuntu.
Regards
Richard
------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Charlie Reinl
2010-08-24 18:34:40 UTC
Permalink
Post by Jussi Lahtinen
I have noticed it with Ubuntu also.
I use Parcellite clipboard manager, I'm not sure if it matters.
That bug is rare and I have not figured out how to reproduce it.
Jussi
Post by richard terry
Post by Benoît Minisini
Post by Phạm Quang Dương
1. Thank you for your response, it works better now.
2.The problem of shortcuts keys Ctrl+C, Ctrl+X is: when I use those
shortcut keys, I can paste only to the Gambas project editor window from
where I copy (I can paste to different tabs). When I switch to other
windows e.g gedit or an other Gambas project window, there's nothing to
paste. But when return to the first Gambas project window, I still can
paste. It's like that the shortcut keys use a "local clipboard" not the
clipboard of system. But this problem doesn't happen with the context
menu. (Paste here include both Ctrl+V and menu).
Strange: it works perfectly as expected there. I copy some text with
CTRL+C, and I paste it in gedit with CTRL+V, and that works!
Regards,
I've changed the topic header - but just to comment here, this is a long
standing and inconsistant problem I've noticed in the linux environment
gambas.
I has has happened more to more when I do ctrl C or use a menu with a copy
option, then switch immediately to gambas and do a Ctrl V or visa-versa.
On the occasions it dosn't work, either nothing pastes, or what pastes was
from some previous copy.
Can't reproduce it not common - but just repeating that it does exist. My two
linux distro's I've experienced this in as ARCH and KUbuntu.
Regards
Richard
Salut,

I'v that troubles also, but I think in my case it's my KVM and/or the
KVM and VMware-Workstation because I'v that on my Ubuntu 8.04 (a real
computer) but also on Mandriva 2010.1 (also a real computer) and on all
VMware-Workstations from SuSE 9.x over BSD to Windows (worst since
Office 2007).

I do not belief, that "Computers" or "OS" have problems with Ctrl+C/+V
--
Cordialement
Charlie
Continue reading on narkive:
Loading...