Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I have 3 href="https://forum.tuteehub.com/tag/scripts">scripts (I have removed the help_page function from the networkstats.sh script when I pasted here to save some space):
api3.href="https://forum.tuteehub.com/tag/php">php
href="https://forum.tuteehub.com/tag/php">php output = shell_exec('/bin/bash /usr/share/href="https://forum.tuteehub.com/tag/nginx">nginx/status/getnetworkstatsin.sh'); echo $output; ?>
getnetworkstatsin.sh
#!/bin/bash ssh -i /tmp/id_rsahref="https://forum.tuteehub.com/tag/1">1 root@centos7clone bash -s -- -I < ./networkstats.sh
networkstats.sh
#!/bin/bash interface=enp0s3 read -r inbytesold outbytesold < <(awk -v dev="^$interface:" '$href="https://forum.tuteehub.com/tag/1">1 ~ dev { sub(/[^:]*:/,""); print $href="https://forum.tuteehub.com/tag/1">1, $9; exit }' /proc/net/dev) sleep href="https://forum.tuteehub.com/tag/1">1 read -r inbytesnew outbytesnew < <(awk -v dev="^$interface:" '$href="https://forum.tuteehub.com/tag/1">1 ~ dev { sub(/[^:]*:/,""); print $href="https://forum.tuteehub.com/tag/1">1, $9; exit }' /proc/net/dev) kilobitsin=$(( ( ( inbytesnew - inbytesold ) * 8 ) / href="https://forum.tuteehub.com/tag/1">1024 )) kilobitsout=$(( ( ( outbytesnew - outbytesold ) * 8 ) / href="https://forum.tuteehub.com/tag/1">1024 )) show_outgoing() { echo $kilobitsout } show_all() { echo "kilobits in: $kilobitsin" echo "kilobits out: $kilobitsout" } if [[ $# -eq 0 ]]; then help_page exit href="https://forum.tuteehub.com/tag/1">1 fi for arg in "$@" do case $arg in -h|--help) help_page ;; -I) show_incoming ;; -O) show_outgoing ;; -A|--all) show_all ;; esac done
The problem I have is that when I execute the api3.href="https://forum.tuteehub.com/tag/php">php script from console, it is able to execute and return a value.
However when I try and execute from a webpage it fails to return anything.
I believe it is not even executing when I load it via the webpage by navigating to localhost/api3.href="https://forum.tuteehub.com/tag/php">php. Can someone help, what is the reason behind this? I have added
href="https://forum.tuteehub.com/tag/nginx">nginx ALL=NOPASSWD: /usr/share/href="https://forum.tuteehub.com/tag/nginx">nginx/status/getnetworkstatsin.sh
To my visudo section, I have tried to change permissions of all files involved to 777 (temporally) without success.
All these href="https://forum.tuteehub.com/tag/scripts">scripts are located inside /usr/share/href="https://forum.tuteehub.com/tag/nginx">nginx/status which href="https://forum.tuteehub.com/tag/nginx">nginx has access to.
You don't have an active console when invoking the script from php. Add the -tt switch to your ssh command.
php
-tt
ssh
-t Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.
Source: man ssh
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 9 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.