Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Problem ze skryptem exec i include
kefu
post
Post #1





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 2.01.2011

Ostrzeżenie: (0%)
-----


Witam przejdę od razu do rzeczy napisałem malutki skrypcik który z poziomu www odpala proces na shellu ale nie działa i nie mam pomysłów jak to zastosować

Kod
  1. <?php
  2. system('cd /home/ts3/teamspeak3-server_linux-x86/');
  3. shell_exec('ts3server_startscript.sh start');
  4. echo '<font color="green">Serwer TS3 Zostal uruchomiony</font>';
  5. ?>


Drugim problemem jest ze apache nie czyta mi include w php i nie wiem co zrobić próbowałem już wszystkiego serwer stoi na starym komputerze jest on przeznaczony pod shella.

Za pomoc z góry dziękuję smile.gif
Pozdrawiam Kefu.
Go to the top of the page
+Quote Post
Krzychu105
post
Post #2





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 2.01.2011

Ostrzeżenie: (0%)
-----


a dlaczego od razu nie zrobisz ?
Kod
shell_exec('/home/ts3/teamspeak3-server_linux-x86/ts3server_startscript.sh start');
Go to the top of the page
+Quote Post
kefu
post
Post #3





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 2.01.2011

Ostrzeżenie: (0%)
-----


Ponieważ to nic nie daje już próbowałem twojego rozwiązania wcześniej smile.gif
Go to the top of the page
+Quote Post
MrMag
post
Post #4





Grupa: Zarejestrowani
Postów: 154
Pomógł: 5
Dołączył: 24.02.2004

Ostrzeżenie: (0%)
-----


zobacz ten temat http://forum.php.pl/index.php?showtopic=86587


--------------------
Go to the top of the page
+Quote Post
kefu
post
Post #5





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 2.01.2011

Ostrzeżenie: (0%)
-----


Nic nie dało niestety... ponieważ nie rozumie funkcji start :/
Go to the top of the page
+Quote Post
MrMag
post
Post #6





Grupa: Zarejestrowani
Postów: 154
Pomógł: 5
Dołączył: 24.02.2004

Ostrzeżenie: (0%)
-----


pokaz kod


--------------------
Go to the top of the page
+Quote Post
sazian
post
Post #7





Grupa: Zarejestrowani
Postów: 1 045
Pomógł: 141
Dołączył: 19.09.2006
Skąd: B-tów

Ostrzeżenie: (0%)
-----


rozumiem że jeśli wpiszesz w konsoli
Kod
/home/ts3/teamspeak3-server_linux-x86/ts3server_startscript.sh start

to wszystko działa questionmark.gif
jeśli tak to najmniejszej linij oporu możesz utworzyć nowy plik i w nim dać
Kod
#!/bin/bash
/home/ts3/teamspeak3-server_linux-x86/ts3server_startscript.sh start

lub dać to w jednym poleceniu
Kod
cd /home/ts3/teamspeak3-server_linux-x86/;./ts3server_startscript.sh start
Go to the top of the page
+Quote Post
kefu
post
Post #8





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 2.01.2011

Ostrzeżenie: (0%)
-----


Tak dobrze rozumiesz myślisz o stworzeniu pliku *.sh i odpaleniu go przez www? Jeżeli tak to nie jest dobry pomysł bo inni użytkownicy będą mieli do niego dostęp.
Go to the top of the page
+Quote Post
sazian
post
Post #9





Grupa: Zarejestrowani
Postów: 1 045
Pomógł: 141
Dołączył: 19.09.2006
Skąd: B-tów

Ostrzeżenie: (0%)
-----


nie,
ja myślałem o stworzeniu pojedynczego pliku i w nim umieszczeniu tego polecenia, a plik byłby uruchamiany dalej z poziomu php
chociaż to może i głupi pomysł biggrin.gif

ale już mam inny winksmiley.jpg
zamiast shell_exec daj exec i zobacz jakiś błąd jest - oczywiście nie błąd php tylko w tym poleceniu
Go to the top of the page
+Quote Post
kefu
post
Post #10





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 2.01.2011

Ostrzeżenie: (0%)
-----


Nie ma żadnego błędu ale w PHP to nie trybie nie wiem dlaczego :/
A w include mam taki błąd

  1. Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /var/www/log.php:2) in /var/www/log.php on line 3
  2.  
  3. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/log.php:2) in /var/www/log.php on line 3


w 3 lini jest


@refresh
Go to the top of the page
+Quote Post
Hekko
post
Post #11





Grupa: Zarejestrowani
Postów: 255
Pomógł: 23
Dołączył: 1.12.2003

Ostrzeżenie: (10%)
X----


A co jest w linii 2 ? Najlepiej to pokaż cały kod.


--------------------
Tani hosting - Hekko.pl | PHP 5.2/5.3/5.4/5.5/5.6 | MySQL 5.5 |
Hosting już od 49 zł rocznie! Domena pl do każdego pakietu!
Go to the top of the page
+Quote Post
ZuyPan
post
Post #12





Grupa: Zarejestrowani
Postów: 116
Pomógł: 4
Dołączył: 4.02.2010

Ostrzeżenie: (0%)
-----


Z tego co wiem taki błąd z include pojawia się gdy do pliku np.
  1. <?php
  2. include ('bla.php');
  3. //reszta kodu


includujesz plik bla.php w którym również zaczynasz sesje czyli
  1. <?php
  2. //reszta kodu



--------------------
Blog
Go to the top of the page
+Quote Post
kefu
post
Post #13





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 2.01.2011

Ostrzeżenie: (0%)
-----


z include naprawiłem błąd to było przez kodowanie winksmiley.jpg ale z tym shell_exec mam nadal problem ;/
Go to the top of the page
+Quote Post
MrMag
post
Post #14





Grupa: Zarejestrowani
Postów: 154
Pomógł: 5
Dołączył: 24.02.2004

Ostrzeżenie: (0%)
-----


Cytat(kefu @ 2.01.2011, 17:20:21 ) *
Tak dobrze rozumiesz myślisz o stworzeniu pliku *.sh i odpaleniu go przez www? Jeżeli tak to nie jest dobry pomysł bo inni użytkownicy będą mieli do niego dostęp.


czemu nie chcesz wlasnie tak zrobic? Kto bedzie mial do tego dostep? Jacy uzytkownicy?


--------------------
Go to the top of the page
+Quote Post
kefu
post
Post #15





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 2.01.2011

Ostrzeżenie: (0%)
-----


wszyscy którzy są na shellu przez 1 *.sh odpalam ale komendy wyskakują nic więcej serwer się nie uruchamia...
Go to the top of the page
+Quote Post
MrMag
post
Post #16





Grupa: Zarejestrowani
Postów: 154
Pomógł: 5
Dołączył: 24.02.2004

Ostrzeżenie: (0%)
-----


pokaz wszystko: kod php i skrypty sh


--------------------
Go to the top of the page
+Quote Post
kefu
post
Post #17





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 2.01.2011

Ostrzeżenie: (0%)
-----


Trochę tego jest :0

Skrypt który powinien uruchomić server
  1. <?php
  2. system("/bin/sh /home/ts/teamspeak3-server_linux-x86/ts3server_startscript.sh start");
  3. ?>


a tutaj plik ts3server_startscript.sh
  1. #!/bin/sh
  2. # Copyright (c) 2010 TeamSpeak Systems GmbH
  3. # All rights reserved
  4.  
  5. COMMANDLINE_PARAMETERS="${2}" #add any command line parameters you want to pass here
  6. BINARYPATH="$(dirname "${0}")"
  7. cd "${BINARYPATH}"
  8. LIBRARYPATH="$(pwd)"
  9.  
  10. if [ -e "ts3server_linux_x86" ]; then
  11. BINARYNAME="ts3server_linux_x86"
  12. elif [ -e "ts3server_linux_amd64" ]; then
  13. BINARYNAME="ts3server_linux_amd64"
  14. elif [ -e "ts3server_freebsd_x86" ]; then
  15. BINARYNAME="ts3server_freebsd_x86"
  16. elif [ -e "ts3server_freebsd_amd64" ]; then
  17. BINARYNAME="ts3server_freebsd_amd64"
  18. else
  19. echo "Could not locate binary file, aborting"
  20. exit 5
  21. fi
  22.  
  23. case "$1" in
  24. start)
  25. if [ -e ts3server.pid ]; then
  26. if ( kill -0 $(cat ts3server.pid) 2> /dev/null ); then
  27. echo "The server is already running, try restart or stop"
  28. exit 1
  29. else
  30. echo "ts3server.pid found, but no server running. Possibly your previously started server crashed"
  31. echo "Please view the logfile for details."
  32. rm ts3server.pid
  33. fi
  34. fi
  35. if [ "${UID}" = "0" ]; then
  36. echo WARNING ! For security reasons we advise: DO NOT RUN THE SERVER AS ROOT
  37. c=1
  38. while [ "$c" -le 10 ]; do
  39. echo -n "!"
  40. c=$((++c))
  41. done
  42. echo "!"
  43. fi
  44. echo "Starting the TeamSpeak 3 server"
  45. if [ -e "$BINARYNAME" ]; then
  46. if [ ! -x "$BINARYNAME" ]; then
  47. echo "${BINARYNAME} is not executable, trying to set it"
  48. chmod u+x "${BINARYNAME}"
  49. fi
  50. if [ -x "$BINARYNAME" ]; then
  51. export LD_LIBRARY_PATH="${LIBRARYPATH}:${LD_LIBRARY_PATH}"
  52. "./${BINARYNAME}" ${COMMANDLINE_PARAMETERS} > /dev/null &
  53. echo $! > ts3server.pid
  54. echo "TeamSpeak 3 server started, for details please view the log file"
  55. else
  56. echo "${BINARNAME} is not exectuable, cannot start TeamSpeak 3 server"
  57. fi
  58. else
  59. echo "Could not find binary, aborting"
  60. exit 5
  61. fi
  62. ;;
  63. stop)
  64. if [ -e ts3server.pid ]; then
  65. echo -n "Stopping the TeamSpeak 3 server"
  66. if ( kill -TERM $(cat ts3server.pid) 2> /dev/null ); then
  67. c=1
  68. while [ "$c" -le 300 ]; do
  69. if ( kill -0 $(cat ts3server.pid) 2> /dev/null ); then
  70. echo -n "."
  71. else
  72. break
  73. fi
  74. c=$((++c))
  75. done
  76. fi
  77. if ( kill -0 $(cat ts3server.pid) 2> /dev/null ); then
  78. echo "Server is not shutting down cleanly - killing"
  79. kill -KILL $(cat ts3server.pid)
  80. else
  81. echo "done"
  82. fi
  83. rm ts3server.pid
  84. else
  85. echo "No server runing (ts3server.pid is missing)"
  86. exit 7
  87. fi
  88. ;;
  89. restart)
  90. $0 stop && $0 start || exit 1
  91. ;;
  92. status)
  93. if [ -e ts3server.pid ]; then
  94. if ( kill -0 $(cat ts3server.pid) 2> /dev/null ); then
  95. echo "Server is running"
  96. else
  97. echo "Server seems to have died"
  98. fi
  99. else
  100. echo "No server running (ts3server.pid is missing)"
  101. fi
  102. ;;
  103. *)
  104. echo "Usage: ${0} {start|stop|restart|status}"
  105. exit 2
  106. esac
  107.  
  108.  


Dałem te 2 najważniejsze!
Go to the top of the page
+Quote Post
MrMag
post
Post #18





Grupa: Zarejestrowani
Postów: 154
Pomógł: 5
Dołączył: 24.02.2004

Ostrzeżenie: (0%)
-----


bardzo nieuwaznie czytales ten temat smile.gif

zobacz

  1. shell_exec("./odpal_serwer > /dev/null");


Kod
#!/bin/sh
/home/ts/teamspeak3-server_linux-x86/ts3server_startscript.sh start &


zobacz czy w ogole skrypt php/sh ma uprawnienia do wywolania tej komendy. zobacz prawa dostepu do niego.


--------------------
Go to the top of the page
+Quote Post
kefu
post
Post #19





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 2.01.2011

Ostrzeżenie: (0%)
-----


Nic nie dało nawet nie wyświetliło ze serwer się odpalił jak to robiło przy system.

Ten post edytował kefu 7.01.2011, 11:37:53
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 17:11