Is it possible to Hello world on a server

Linux specific questions.
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Is it possible to Hello world on a server

Postby owen » Aug 17, 2019 2:46

Got this harebrained idea to compile hello world and call it using PHP shell exec.

It didn't work.

I changed permissions to 777 that's about all I can think to do.

I tried two different things first to just simply echo "hello world"

Hello.bas
Print "hello world"
Compiled and tested in ubuntu

Uploaded to my server along with the PHP file

http://fbcadcam.com/hello/



<?php
$output = shell_exec('hello');
echo "<pre>$output</pre>";
?>

Any ideas how to do something like this?
Last edited by owen on Aug 17, 2019 2:54, edited 1 time in total.
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: Is it possible to Hello world on a server

Postby owen » Aug 17, 2019 2:49

Oops sorry the second thing I tried to do was to print to a file

Hello.bas
Open "test.txt" for output as #1
Print #1, "hello"
Close #1

Works fine and ubuntu
But I don't think it's running on the server when I call using PHP shell
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: Is it possible to Hello world on a server

Postby owen » Aug 17, 2019 10:21

Maybe the compiled hello program (compiled in ubuntu) won't run in other linux flavors
Knatterton
Posts: 165
Joined: Apr 19, 2019 19:03

Re: Is it possible to Hello world on a server

Postby Knatterton » Aug 17, 2019 10:48

The compiled hello should work on commandline in each normal linux like all the programs in /bin. So if "ls" works "./hello" should work.
badidea
Posts: 2178
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Is it possible to Hello world on a server

Postby badidea » Aug 17, 2019 19:21

Else 32 vs 64 bit issue? (machines different)
Knatterton
Posts: 165
Joined: Apr 19, 2019 19:03

Re: Is it possible to Hello world on a server

Postby Knatterton » Aug 17, 2019 20:08

So can it be it must be $output = shell_exec('./hello'); ?
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: Is it possible to Hello world on a server

Postby owen » Aug 17, 2019 23:17

Without the ./ php echos
Hello!
With the ./
I get the error
Error while loading shared libraries unsupported version 256 of Verneed record
speedfixer
Posts: 430
Joined: Nov 28, 2012 1:27
Location: California

Re: Is it possible to Hello world on a server

Postby speedfixer » Aug 17, 2019 23:28

There are still many libraries either linked statically or dynamically to an FB executable and each linux system isn't guaranteed to have same library versions. So, one compiled and moved to another system is not guaranteed to work, unless you know all about the pedigree of both systems.

When you console in to a remote linux system and run a program there, you can even see graphics locally. (From windows to linux, something like Xming.) But the program is run on its host(remote) and X11 takes care of showing you what you see. Not the same thing.

Anything else and the trick is how you wrap it up and serve it out.

Stream a file, capture the console output, something like that.

Look at pipes, maybe.

david
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: Is it possible to Hello world on a server

Postby owen » Aug 17, 2019 23:45

Not knowing how to redirect the output from my hello program thru http i figured well until then i might as well use php shell exec
https://www.php.net/manual/en/function.shell-exec.php
to handle that.

this works on my bluehost server no problem

Code: Select all


<?php
$output = shell_exec('ls -lart');
echo "<pre>$output</pre>";
?>



i figured a simple (minimal) hello word program would work.

i chatted with bluehost tech and they say no problem with my account it should work.

so maybe its like u say, more resources are required to run hello world
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: Is it possible to Hello world on a server

Postby owen » Aug 17, 2019 23:58

i wonder is there a way when compiling hello world ie. Print "hello world" to specify the most common linux resources (libraries)
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: Is it possible to Hello world on a server

Postby owen » Aug 18, 2019 0:02

note:
$output = shell_exec('ls -lart');
doesn't require ./
ie.
$output = shell_exec('./ls -lart');

i wonder what language ls was written / compiled in
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: Is it possible to Hello world on a server

Postby owen » Aug 18, 2019 0:12

Look at pipes, maybe.


when you say pipes i think that the same as dos MORE or >
ie dir *.* > myfilelist.txt

i did try this and it does produce a file but only with the same results when not using ./
ie the output was same as shown in the browser hello!

Code: Select all

<?php
# works, but output is lost
shell_exec("my_script.sh 2>/dev/null >/dev/null &");
?>


if it wasn't that php example code then it was one of the others

my last compiled hello.bas was to print and write to a text file neither worked

Code: Select all

print "hello world text file saved"
open "helloworld.txt" for output as #1
print #1, "hello world"
close #1
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: Is it possible to Hello world on a server

Postby owen » Aug 18, 2019 0:27

owen@owen-Latitude-E6420:~/test$ ldd hello
linux-gate.so.1 (0xf7fa7000)
libtinfo.so.5 => /lib32/libtinfo.so.5 (0xf7f67000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf7e65000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf7e60000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xf7e41000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7c65000)
/lib/ld-linux.so.2 (0xf7fa9000)
owen@owen-Latitude-E6420:~/test$
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: Is it possible to Hello world on a server

Postby owen » Aug 18, 2019 0:28

maybe it's a 32 bit vs 64 bit issue
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: Is it possible to Hello world on a server

Postby owen » Aug 18, 2019 0:33

ps this dosen't work on the server

Code: Select all

<?php
$output = shell_exec("ldd hello");
echo "<pre>$output</pre>";
?>

Return to “Linux”

Who is online

Users browsing this forum: No registered users and 1 guest