[Glass] Execution a simple "cp command ...
James Foster via Glass
glass at lists.gemtalksystems.com
Fri Jun 12 10:23:44 PDT 2015
Hi Marten,
It turns out that GsHostProcess does not handle single quoted strings quite right. We have reported this internally as bug #45386. The work-around is to reverse your use of single and double quotes:
| aGsHostProcess output aWriteStream source target command |
source := '/foo/bar.1'.
target := '/foo/bar.2'.
aWriteStream := WriteStream on: String new.
aWriteStream
nextPutAll: '/bin/bash -c "cp ''' ;
nextPutAll: source asString ;
nextPutAll: ''' ''';
nextPutAll: target asString ;
nextPutAll: '''"' .
command := aWriteStream contents.
aGsHostProcess := GsHostProcess fork: command.
aWriteStream := WriteStream on: String new.
(Delay forSeconds: 1) wait.
aWriteStream
nextPutAll: 'original command is '; lf; tab;
nextPutAll: command; lf;
nextPutAll: 'childHasExited is ';
nextPutAll: aGsHostProcess childHasExited printString; lf;
nextPutAll: 'childStatus is ';
nextPutAll: aGsHostProcess childStatus printString; lf;
nextPutAll: 'commandLine is '; lf; tab;
nextPutAll: aGsHostProcess commandLine; lf;
nextPutAll: 'processId is ';
nextPutAll: aGsHostProcess processId printString; lf;
nextPutAll: 'stderr is '; lf; tab;
nextPutAll: (aGsHostProcess stderr readWillNotBlock
ifTrue: [aGsHostProcess stderr readString: 1024]
ifFalse: ['']); lf;
nextPutAll: 'stdout is '; lf; tab;
nextPutAll: (aGsHostProcess stdout readWillNotBlock
ifTrue: [aGsHostProcess stdout readString: 1024]
ifFalse: ['']); lf;
yourself.
aWriteStream contents.
original command is
/bin/bash -c "cp '/foo/bar.1' '/foo/bar.2'"
childHasExited is true
childStatus is 127
commandLine is
/bin/bash -c "cp '/foo/bar.1' '/foo/bar.2'"
processId is nil
stderr is
/bin/bash: cp '/foo/bar.1' '/foo/bar.2': No such file or directory
stdout is
See if this works for you.
James
> On Jun 11, 2015, at 12:12 PM, itlists at schrievkrom.de via Glass <glass at lists.gemtalksystems.com> wrote:
>
> ... seems to e pretty difficult ...
>
> I tried stuff like:
>
> GsHostProcess>>mskCopyFile: source to: target
> | aGsHostProcess output aWriteStream |
>
> aWriteStream := WriteStream on: String new.
> aWriteStream
> nextPutAll: '/bin/bash -c ' ;
> nextPut: $' ;
> nextPutAll: 'cp ' ;
> nextPut: $" ;
> nextPutAll: source asString ;
> nextPut: $" ;
> space ;
> nextPut: $" ;
> nextPutAll: target asString ;
> nextPut: $" ;
> nextPut: $' .
>
> Transcript cr ; show: aWriteStream contents.
>
> aGsHostProcess := GsHostProcess fork: aWriteStream contents.
> ....
>
> When executing stuff like
>
> GsHostProcess
> mskCopyFile: '/var/www/fileswebcati/customers/test.txt'
> to: '/var/www/fileswebcati/customers/test2.txt'
>
> the following command is printed on the Transcript:
>
> /bin/bash -c 'cp "/var/www/fileswebcati/customers/test.txt"
> "/var/www/fileswebcati/customers/test2.txt"'
>
> executing it in a real shell: everything is ok.
>
> So: anyone telling me, how a simple "cp" can be executed under Gemstone ...
>
>
> Marten
>
>
> --
> Marten Feldtmann
> _______________________________________________
> Glass mailing list
> Glass at lists.gemtalksystems.com
> http://lists.gemtalksystems.com/mailman/listinfo/glass
More information about the Glass
mailing list