0

the command line is: imapsync \ --host1 test1.lamiral.info --user1 test1 --password1 secret1 \ --host2 test2.lamiral.info --user2 test2 --password2 secret2 so I write it in a file script.sh and I gave it chmod +x ... and now I want it to be executed when I click the button btn1 so what js function should I use x?

helmi
  • 3
  • 4
  • Where would this script be run? – evolutionxbox Aug 24 '21 at 12:31
  • If you think you can execute shell commands from the browser html then you are wrong my friend; Browsers are *sandboxed* from the host and can't execute commands on it. – Lakshaya U. Aug 24 '21 at 12:33
  • @evolutionxbox on a ubuntu server – helmi Aug 24 '21 at 12:33
  • A browser can only connect to a server by http (afaik). – evolutionxbox Aug 24 '21 at 12:34
  • @evolutionxbox it just a simple shell command like ls or cd that zill be run in background i found something similar with node js I think like this code: 'var exec = require('child_process').exec, child; child = exec('cat *.js bad_file | wc -l', function (error, stdout, stderr) { console.log('stdout: ' + stdout); console.log('stderr: ' + stderr); if (error !== null) { console.log('exec error: ' + error); } }); child(); ' – helmi Aug 24 '21 at 12:40
  • Yeah. Why not use node to listen to a post/get request (with credentials) which runs you shell script? Make sure to secure the endpoint though. – evolutionxbox Aug 24 '21 at 12:41
  • @evolutionxbox I'm a beginner with node js, I don't know what is the exact function should I use. – helmi Aug 24 '21 at 12:47
  • Firstly there's https://stackoverflow.com/questions/44647778/how-to-run-shell-script-file-using-nodejs – evolutionxbox Aug 24 '21 at 12:51

0 Answers0