I want to run bash script and python script from PERL server-client script. Connection works and if send command via client gets right answer, for example "DATE" gets me current date in client terminal. I want to run bash script in client terminal window taping "SCRIPT" but now it's run on server terminal window. Can I fix it and run script in client terminal window? Maybe solution is simple but now I have no idea. Thank you in advance for help.
My piece of code how I try to run my script
foreach ($buf) {
/^SCRIPT$/ and
print ($sock system("/bin/bash /path/to/my/bash_script")),
last;
/^DATE$/ and
print($sock
scalar(localtime),
"\n"),
last;
print $sock "NO OPTION\n";
}
EDIT:
In reference to the comment i change this line:
print ($sock system("/bin/bash /path/to/my/bash_script"))
to this:
print ($sock `/bin/bash /path/to/my/bash_script`)
This works perfectly for python script. For bash script that is interactive this not works correct. This is bash simple game using tput to color game area.
Interactivity - controls in game:
local key=$(cat -v)
local dy=0
local dr=0
if [ "$key" == "w" ]; then
dy=$((dy-2))
fi
if [ "$key" == "s" ]; then
dy=$((dy+2))
fi
if [ "$key" == "^[[A" ]; then
dr=$((dr-2))
fi
if [ "$key" == "^[[B" ]; then
dr=$((dr+2))
fi
And main loop is something like that:
while [key "e" for exit not down] then
interactivity()
draw_game_area()
increase_iteration++
sleep 0.1
done;