How to close a running program from an Alaskan program
Posted: Mon Feb 03, 2020 8:21 pm
Running a program for execution from a program in Alaska is no problem. But how do I close a running program from an Alaskan program?. For example, how do I close the browser from a program in Alaska? I mean close the external program unconditionally, as from the task Manager to close the process.
Example. I'm running an on-line translator: http://aidos.byethost5.com/translate.php. A browser window Opens with the translation. Now it is necessary to close this window or better to close the browser itself. This should be done without the user's participation, i.e. programmatically. I don't care which program to close it from: php or Alaska. But it seems impossible to do this from php.
It would be ideal to launch the translator without opening the browser at all. The fact is that the file for translation, the translation direction and the translated file: all this is uploaded and downloaded via ftp by my program. You don't need a browser at all.
[/size]
Example. I'm running an on-line translator: http://aidos.byethost5.com/translate.php. A browser window Opens with the translation. Now it is necessary to close this window or better to close the browser itself. This should be done without the user's participation, i.e. programmatically. I don't care which program to close it from: php or Alaska. But it seems impossible to do this from php.
It would be ideal to launch the translator without opening the browser at all. The fact is that the file for translation, the translation direction and the translated file: all this is uploaded and downloaded via ftp by my program. You don't need a browser at all.
Code: Select all
<?php
// Документация к API Яндекс-переводчика txt-файлов: https://yandex.ru/dev/translate/
$key = 'My key'; // Получить ключ: https://yandex.ru/dev/translate/doc/dg/concepts/api-keys-docpage/
$text = file_get_contents('text_ru.txt'); // Текст должен быть в кодировке UTF-8 или если он в другой - то надо здесь его перекодировать
$text = iconv('CP866', 'UTF-8', $text); // Перекодирование текста из DOS-TXT OEM866 в UTF-8
$lang = file_get_contents('lang.txt'); // Файл, в котором задано направление перевода, например: 'ru-en'
$params = array( 'key' => $key , 'text' => $text, 'lang' => $lang,); // Задать направление перевода: 'ru-en'
$query = http_build_query($params);
$response = file_get_contents('https://translate.yandex.net/api/v1.5/tr.json/translate?'.$query);
$data = json_decode($response, true);
$text = $data['text'][0];
echo $text;
// Перекодирование текста из windows-1251 в UTF-8, хотя на хосте файл виден как бы в кодировке windows-1251, когда его скачаешь на комп он и так оказывается уже в utf-8
//$text = iconv('windows-1251', 'UTF-8', $text);
$fp = fopen("text_transl.txt", "w"); // открываем файл, если файл не существует, делается попытка создать его
fwrite($fp, $text); // записываем в файл текст
fclose($fp); // закрываем
?>