Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. How to add linux command and syspath
Forum Updated to NodeBB v4.3 + New Features

How to add linux command and syspath

Scheduled Pinned Locked Moved Unsolved C++ Gurus
2 Posts 2 Posters 421 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Beginner_to_code
    wrote on 19 Jun 2021, 11:54 last edited by SGaist
    #1

    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();
    
    }
    
    J 1 Reply Last reply 19 Jun 2021, 11:58
    0
    • B Beginner_to_code
      19 Jun 2021, 11:54

      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();
      
      }
      
      J Online
      J Online
      JonB
      wrote on 19 Jun 2021, 11:58 last edited by
      #2

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

      FWIW, your code is 100% non-Qt.

      1 Reply Last reply
      0

      1/2

      19 Jun 2021, 11:54

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved