Results 1 to 8 of 8

Thread: i cant able to mount my pendrive using qprocess

  1. #1
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default i cant able to mount my pendrive using qprocess

    i created one script file (script.sh) inside that file i have written the command to mount
    Qt Code:
    1. sudo mount -o umask=0 /dev/sdb1 /media/usb
    To copy to clipboard, switch view to plain text mode 
    i called this file using Qprocess,the result its mounted,
    Qt Code:
    1. int Widget::process()
    2. {
    3. QProcess transcodescript;
    4. QStringList arguments;
    5. QString program ="/bin/sh";
    6. arguments << SCRIPTFILEPATH;
    7. transcodescript.start(program, arguments);
    8. status=transcodescript.waitForFinished(-1);
    9. if(!status)
    10. {
    11. qDebug()<<"failed to mount";
    12. }
    13. return SUCCESS;
    14. }
    To copy to clipboard, switch view to plain text mode 
    i dont get any error for this above command,but when i use that command in terminal its get mounting,,i know am doing some mistakes please can any one give me solution for this.
    Thanks in Advance

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: i cant able to mount my pendrive using qprocess

    In the case of manual invocation you might have used sudo before and entered the password there so you were already authenticated when sudo of the script ran.

    You could try using the -S option to make sudo ask for the password on stderr and read it from stdin, or provide a program to --askpass or configure one (all documented in the sudo man page).

    Of course using sudo assumes that the user running you program has the permission to use sudo to gain elevated privilegdes.
    But then again, even having code to mount suggests that you are not targetting a desktop system but more likely some custom setup and can configure the system appropriately.

    Cheer,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    iswaryasenthilkumar (16th September 2015)

  4. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: i cant able to mount my pendrive using qprocess

    If SCRIPTFILEPATH is a relative path then the whole thing could be failing* because the current working directory is not where you think it is.

    *your original post indicates that everything is working but I assume it is not.

  5. The following user says thank you to ChrisW67 for this useful post:

    iswaryasenthilkumar (18th September 2015)

  6. #4
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: i cant able to mount my pendrive using qprocess

    i checked in my pc ubuntu Linux (Filesystem -> /dev/sdb1 )->this will be created when i insert my pendrive
    so i used command
    Qt Code:
    1. sudo mount /dev/sdb1 /media/usb
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. sudo mount -o umask=0 /dev/sdb1 /media/usb
    To copy to clipboard, switch view to plain text mode 
    i checked both command in my terminal both command are mounted my pendrive,,but when i used this command by using Qprocess command not working and my pendrive not get mounted
    my SCRIPTFILEPATH in home directory
    Quote Originally Posted by ChrisW67 View Post
    If SCRIPTFILEPATH is a relative path then the whole thing could be failing* because the current working directory is not where you think it is.

    *your original post indicates that everything is working but I assume it is not.

    Added after 1 18 minutes:


    i have one more doubt in this when i use sudo in terminal it will ask password to execute the command like wise i assigned command in my script
    Qt Code:
    1. sudo mount-o umask=0 /dev/sdb1 /media/usb
    To copy to clipboard, switch view to plain text mode 
    ,,i need to pass the password in Qprocess how to assign my password using Qprocess,can any one help me o rectify this problem
    Last edited by iswaryasenthilkumar; 18th September 2015 at 07:52.

  7. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: i cant able to mount my pendrive using qprocess

    Quote Originally Posted by iswaryasenthilkumar View Post
    i need to pass the password in Qprocess how to assign my password using Qprocess,can any one help me o rectify this problem
    You give no indication which of the suggested options you have already tried.

    Cheers,
    _

  8. #6
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: i cant able to mount my pendrive using qprocess

    i rechanged my command in script
    Qt Code:
    1. sudo mount -o umask=0 /dev/sdb1 /media/usb | grep welcome@1
    To copy to clipboard, switch view to plain text mode 
    welcome@1 is password for sudo command
    i tries this in terminal its working but its not working through app
    Quote Originally Posted by anda_skoa View Post
    You give no indication which of the suggested options you have already tried.

    Cheers,
    _
    Last edited by iswaryasenthilkumar; 18th September 2015 at 10:18.

  9. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: i cant able to mount my pendrive using qprocess

    Quote Originally Posted by iswaryasenthilkumar View Post
    i rechanged my command in script
    Qt Code:
    1. sudo mount -o umask=0 /dev/sdb1 /media/usb | grep welcome@1
    To copy to clipboard, switch view to plain text mode 
    welcome@1 is password for sudo command
    That might very well be, but here you are grepping (filtering) the output of the command for the password.

    Instead of doing things that do not even have the potential of having a positive impact, why don't you try some of the suggestions that might?

    Cheers,
    _

  10. The following user says thank you to anda_skoa for this useful post:

    iswaryasenthilkumar (18th September 2015)

  11. #8
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: i cant able to mount my pendrive using qprocess

    i used this command
    Qt Code:
    1. echo welcome@1 | sudo -S mount -o umask=0 /dev/sdb1 /media/usb
    To copy to clipboard, switch view to plain text mode 
    its worked both in terminal and Qprocess
    Thank you anda_skoa
    Quote Originally Posted by anda_skoa View Post
    That might very well be, but here you are grepping (filtering) the output of the command for the password.

    Instead of doing things that do not even have the potential of having a positive impact, why don't you try some of the suggestions that might?

    Cheers,
    _

Similar Threads

  1. Replies: 1
    Last Post: 3rd June 2013, 13:11
  2. Replies: 0
    Last Post: 23rd March 2013, 19:23
  3. Replies: 0
    Last Post: 26th August 2010, 10:44
  4. QFileSystemWatcher on a network mount
    By TMan in forum Qt Programming
    Replies: 5
    Last Post: 19th February 2010, 07:41
  5. Need help on mount nfs drive in Qt
    By tho97 in forum Qt Programming
    Replies: 3
    Last Post: 28th November 2007, 19:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.