VPL with Portugol Studio

VPL with Portugol Studio

by Osvaldo Novais Júnior -
Number of replies: 3

Hi,

I'm trying to use VPL with Portugol Studio (https://github.com/UNIVALI-LITE/Portugol-Studio). I used a vpl_run.sh file like in Python:

#! /bin/bash

echo "#! /bin/bash" > vpl_execution
echo "portugol-console Diferenca.por" >> vpl_execution
chmod +x vpl_execution

I received the follow error message in the VPL terminal:

"ERRO: /tmp/portugol/programas/Programa1597169405331.java (Permission denied). line: 0, Column: 0" 

Someone can help me to solve this problem?

Thanks!

Average of ratings: -
In reply to Osvaldo Novais Júnior

Re: VPL with Portugol Studio

by Juan Carlos Rodríguez-del-Pino -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Dear Osvaldo,
please, detail what are you trying to do with VPL.
With the message you posted, I only can say that the program you run "portugol-console" generates an error message when acceding to a java file stored in the temp directory.
But I think that this gives no help.

Best regards,
Juan Carlos.
In reply to Juan Carlos Rodríguez-del-Pino

Re: VPL with Portugol Studio

by Osvaldo Novais Júnior -
Dear Juan Carlos,

Thank's for your reply. I'm trying to use PortugolCore compiler to run and avaluate codes on VPL. PortugolCore is a set of tools (parser, semantic analyzer and interpreter) developed using the Java language for the programming language Portugol created at UNIVALI in Brazil. It is supported by Linux. For instance, the execution of the file HelloWorld.por:

programa
{
funcao inicio ()
{
escreva("Hello World!\n")
}
}


in an terminal linux: $ portugol-console HelloWorld.por

The script executar-console-linux.sh for portugol-console is:


#!/bin/sh

caminho_script=$(readlink -f "$0")
caminho_portugol=$(dirname "$caminho_script")
caminho_aplicacao="$caminho_portugol/aplicacao"
caminho_java="$caminho_portugol/java/java-linux/bin/java"

clear

numero_parametros=$#

comando="'$caminho_java' -jar -server -Xms32m -Xmx256m -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 -XX:+UseG1GC -XX:+CMSClassUnloadingEnabled -Dvisualvm.display.name=Portugol-Studio portugol-console.jar"

if [ $numero_parametros -gt 0 ]; then

if [ -f "$1" ]; then

arquivo=$(readlink -f "$1")
else

arquivo="$1"
fi

shift

comando="$comando '$arquivo' $@"
fi

cd "$caminho_aplicacao"
sh -c "$comando"



I'm trying on VPL this vpl_run.sh script:

#! /bin/bash
# vpl_run.sh
echo "#! /bin/bash" > vpl_execution
echo "portugol-console HelloWorld.por">> vpl_execution
chmod +x vpl_execution


But, when a run the code i've received the message:

"ERRO: /tmp/portugol/programas/Programa1597630858646.java (Permissão negada). Lin
ha: 0, Coluna: 0"

I would like to know if it is possible to use VPL to run and evaluate Portugol codes automatically on VPL.

Thanks a lot!
Osvaldo Novais.
In reply to Osvaldo Novais Júnior

Re: VPL with Portugol Studio

by Juan Carlos Rodríguez-del-Pino -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Osvaldo,
The problem is that the program "portugol-console" uses the "/tmp" directory in a way that VPL does not allow to use.
The solution is to indicate to the program "portugol-console" that use another temporary directory.
After different tries, I managed to run "portugol-console" on VPL.
I have made the following changes to "portugol-console" to get it running on VPL.
1) I have changed the "caminho*" vars due to the need to locate the script in another place. Notice that now the location of the Portugol-studio installation is fixed at "/usr/bin/portugol-studio".
2) I have modified the launch of the portugol-console.jar to indicate the new tmpdir location using "-Djava.io.tmpdir=$TMPDIR"

Finally, I have changed your "vpl_run.sh" to create the temporal directory and define the TMPDIR var. Also, I added the common_script.sh and replaced your fixed file name for $VPL_SUBFILE0, the first filename submitted.

I attached the "vpl_run.sh" content. Remember to use the  VPL feature "based on" to simplify the creation of activities that use Portugol.

Best regards,

Juan Carlos.

#! /bin/bash
# vpl_run.sh
. common_script.sh

# Creates local tmp dir
TMPDIR=/home/$USER/.tmp
mkdir -p $TMPDIR

VPLportugol=./vplportugol-console

cat >$VPLportugol << 'ENDSCRIPT'
#!/bin/sh
caminho_portugol=/usr/local/portugol-studio
caminho_aplicacao="$caminho_portugol/aplicacao"
caminho_java="$caminho_portugol/java/java-linux/bin/java"

numero_parametros=$#

comando="'$caminho_java' -jar -server -Xms32m -Xmx256m -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 -XX:+UseG1GC -XX:+CMSClassUnloadingEnabled -Djava.io.tmpdir=$TMPDIR -Dvisualvm.display.name=Portugol-Studio portugol-console.jar"

if [ $numero_parametros -gt 0 ]; then
    if [ -f "$1" ]; then
        arquivo=$(readlink -f "$1")
    else
        arquivo="$1"
    fi
    shift
    comando="$comando '$arquivo' $@"
fi

cd "$caminho_aplicacao"
sh -c "$comando"
ENDSCRIPT

chmod +x $VPLportugol

echo "#! /bin/bash" > vpl_execution
echo "export TMPDIR=$TMPDIR" >> vpl_execution
echo "$VPLportugol $VPL_SUBFILE0">> vpl_execution
chmod +x vpl_execution
Attachment Captura.JPG