[Gambas-user] More Problems with SHELL (possible BUG).

audiossis audiossis at ...867...
Thu Jul 5 13:58:48 CEST 2007


Hello,

I have noticed a problem with using the "SHELL" command to execute console functions and then 
return the output of those functions to a "Process_read" sub.
For the most part this seems to work quite well. When "rm" to remove files or when using "cp" to copy files using the code:

PUBLIC SUB something()

SHELL "cp -var /some/directory/some/file /another/directory/another/place" WAIT FOR READ

END

PUBLIC SUB Process_read()

DIM sOut AS String
hStream = OPEN "/path/to/log/file" FOR APPEND

READ #LAST, sOUT, -256
PRINT #hStream, sOUT

END


The output of "cp" is returned and printed to the log file. However this is not the case when using "mkdir" with the following code:


PUBLIC SUB something()

SHELL "mkdir -v /new/directory" WAIT FOR READ

END

PUBLIC SUB Process_read()

DIM sOut AS String
hStream = OPEN "/path/to/log/file" FOR APPEND

READ #LAST, sOUT, -256
PRINT #hStream, sOUT

END


This produces absolutely no output to the log file whatsoever. but if I remove the "FOR READ" argument I can clearly see the output of the
 "mkdir" in the GAMBAS console. The same can be said for using the "cpio" command to create backup archives in the same manner. 
The command executes but "READ" does not receive the output from the command therefore no output is made to the log file.

I have also noticed that using "cd" or "pushd" to traverse filesystems is difficult at best from within GAMBAS. For example, if I use this code:

SHELL "pushd /directory"
SHELL "find ./ | cpio -vco | gzip > /path/to/archive/file"

Then the only files I get into my archive, are the GAMBAS files from the directory where GAMBAS itself was executed.

Unless you use these commands within the same "SHELL" statement as another command like this:

SHELL "pushd /directory; find ./ | cpio -vco | gzip > /path/to/archive/file"

You cannot traverse the filesystem to another directory. It seems that any effect had by "pushd" or "cd" is undone as soon as the current "SHELL" 
statement is finished and your current filesystem location returns to the GAMBAS execution directory. I must say that this is most frustrating when
combined with the other problems outlined above.



Does anyone have any ideas about how to get around any of these issues? 

Oh and by the way "EXEC" does not seem to return ANY command output 
at all to the "FOR READ" argument, regardless of which command is executed on the console.


Any help or work suggestions at all would be greatly appreciated!

Ben Phillips
audiossis at ...867...


-------------------------------------------------------




More information about the User mailing list