Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to add linux command and syspath



  • Hi all,
    This is my code, i want to reboot the machine by giving the reboot command with the given path in bash script shown here

    echo "Reboot System"
    			echo ""
    			echo -n "This will end the demo.  Continue (Y/n)? "
    
    			read continue
    			echo ""
    			if [ "$continue" != "n" ] && [ "$continue" != "N" ]; then
    				cat <<-EOF
    				Set reboot scope to System
    				Command: echo system > /sys/firmware/zynqmp/shutdown_scope
    				EOF
    
    				echo `echo system > /sys/firmware/zynqmp/shutdown_scope`
    				echo ""
    				echo "Command: reboot"
    				echo ""
    				reboot
    				while true; do
    					read dummy
    				done
    			fi
    			;;
    

    Somebody tell me how to solve this.

    #include <stdio.h>
    #include <string.h>
    #include <unistd.h>
    
    void Reboot_System()
    {
        char option;
        printf("\nReboot System\n");
        printf(".................");
        printf("\n This will end the demo. Continue (Y/N)?");
        scanf("%c", &option);
        if (option ==  'y' || option == 'Y')
        {
            std::string sysfspath ("/sys/firmware/zynqmp/shutdown_scope");
    
            printf("\n Reboot\n");
    
        }
    }
    int main()
    {
    
            printf("\nPower Management");
            printf("\n................");
    
            Reboot_System();
    
    }
    


  • @Beginner_to_code
    Don't know what the question actually is.

    FWIW, your code is 100% non-Qt.


Log in to reply