Results 1 to 8 of 8

Thread: i cant able to mount my pendrive using qprocess

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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)

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.