Find the answer to your Linux question:
Results 1 to 7 of 7
Hi Is there a way I can run myProgram when desktop appears no matter if root , administrator, desktop user or an unprivileged user logs in? I actually developed a ...
  1. #1
    Just Joined!
    Join Date
    Dec 2009
    Posts
    12

    Startup script unable to mount a partition...

    Hi


    Is there a way I can run myProgram when desktop appears no matter if root , administrator, desktop user or an unprivileged user logs in?



    I actually developed a script which I set to run at startup i.e. when the Desktop appears. Script runs finely but can't mount a partition. In the script I mounted a partition using
    Code:

    sudo mount /dev/sda1 /mnt &> result.txt

    After executing script a file named result.txt was created which contained
    Code:

    sudo: no tty present and no askpass program specified

    In other words the mounting failed. If I run the script myself from the terminal using sudo ./myProgram i don't face this problem and the drive gets mounted successfully.
    Any suggestions please....

  2. #2
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    616
    you probably have a line in your sudoers file that says:
    Code:
    Defaults    requiretty
    this keeps sudo code from being executed if no tty is present that it was called from. So you can comment it out, and it will work.
    linux user # 503963

  3. #3
    Just Joined!
    Join Date
    Dec 2009
    Posts
    12
    Sorry I did not have

    Code:
    Defaults requiretty
    but I do have

    Code:
    Defaults env_reset
    I commented it out but the problem prevails.

    In case my question is not clear, let me put it again:

    I want a program to run (which copies a partition into another partition) at startup whenever a user gets to Desktop, no matter if he is root, admin, unprivileged or simple Desktop user. The Desktop or unprivileged user must not have permission to copy partitions themselves but my startup program should be able to copy partitions in background when these users log in. Is it possible?

  4. #4
    Just Joined!
    Join Date
    Dec 2009
    Posts
    12

    Problem with executing a startup script.... [Updated]

    Hi

    The main question:

    Is there a way I can run 'completely' one of my script when ubuntu's desktop appears no matter if root , administrator, desktop user or an unprivileged user logged in?

    What does the script do?

    The script mounts a partition, looks for a file in that partition and finally on the basis of that file a decision of copying a partition to another partition is made. That copying is done via

    Code:
    dd if=/dev/sda2 of=/dev/sda5

    When does the script run finely?


    Script runs smoothly when I run it from the terminal by

    Code:
    sudo ./my_copying_script
    This command asks me for the password of currently logged in user. I enter the password and the script starts working.

    When does the script NOT run finely?

    I want to run the script at startup. I set it a startup program by using the Startup Applications utility of Ubuntu. Script ran at startup but exited at the dd command returing following error:

    Code:
    dd: opening '/dev/sda2': Permission denied
    I then prefixed the dd with sudo as mentioned below

    Code:
     sudo dd if=/dev/sda2 of=/dev/sda5
    but this returned following error:
    Code:
    sudo: no tty present and no askpass program specified
    Any suggestions please?

  5. #5
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    616
    perhaps i'm missing something here but if these are fixed partitions why not just make a fstab entry to mount them? then just have a script that copies to and from the partitions in question whenever they logon.
    linux user # 503963

  6. #6
    Linux Newbie previso's Avatar
    Join Date
    Jan 2010
    Location
    SC
    Posts
    115
    I don't know much about scripting, but it seems to me root owns the script, hence it runs only when sudo is logged. Right click and "properties" , "permissions" the script, and enable "others", including group, to execute the script. (maybe?)
    From the follow up posting, it seems sudo and you have privilege to access the disk, but not "others", that may limit the functionality of the script without a log-in.
    Last edited by previso; 04-16-2010 at 12:53 AM. Reason: Add content

  7. #7
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,096
    Hello, usmanajmal

    Duplicate threads are not allowed on the forums so I'm merging the two threads that you've created and you can carry on here regarding this topic.
    oz

    new members/users: read this first | new member faq
    no private messages requesting computer support - post them on the forums!
    please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...