Display output of bash command line on html page using javascript -


i have bash script written customized commands output data in text format. have button on webpage when clicked, takes user page displays output of command. simple example, let's user clicks 'pwd' button. next page display /usr/somedirectory or similar.

i'm new javascript , html have been playing around http , post methods along researching bit on websockets. best way go this?

one way go redirect output of bash command text file (ex.: command1.txt), this:

pwd > /folder/command1.txt 

and open new html page have file command1.txt embedded on object, this:

<object data="/folder/command1.txt" type="text/plain"></object> 

you create new html page , .txt file each command button have. also, advisable put "sleep" or delay of 1 second or (depending on configuration) display html page system has enough time create command file.

also, discussed on comment section of question, careful allowing run can create security problem.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -