LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-27-2013, 08:46 AM   #1
rohaanembedded
Member
 
Registered: May 2013
Location: India
Distribution: Ubuntu 11.10
Posts: 178

Rep: Reputation: Disabled
Exclamation Not able to open the gnome-terminal through bash script on hot plug event.


Dear everyone,

sir i am able to catch the hot plug event of USB device through udev .rule. Even i am able to run ma bigger code with the help of bash scripting only on the event.
but as i am interested in executing the my interactive code on new terminal. so i tried so much to open terminal with "gnome-terminal" command through script.
but its not working fine with udev .rule file, its not opening the terminal on hot plug event. if i ran the script indpendently like ./d.sh to open terminal through this script, everythng goes fine.
seriously need the help Now plzZZZ

for more understanding,

mY udev rules is which call a script run.sh
Quote:
on hot plug run_code.sh is executed
Code:
# Cypress USB vendor ID = 0x0d85
KERNEL=="*", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ACTION=="add", ATTR{idVendor}=="0d85", MODE="666", TAG="cyusb_dev", RUN+="/usr/bin/run_code.sh A"
KERNEL=="*", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ACTION=="remove", TAG=="cyusb_dev", RUN+="/usr/bin/run_code.sh R"
run_code.sh is
Code:
#!/bin/bash

nohup /home/ivb/"d.sh" &

exec /bin/bash
~
d.sh is script which calls gnome-terminal like
Code:
#!/bin/bash

sleep 1

/usr/bin/gnome-terminal

exec /bin/bash
1.why this gnome-terminal is not opening??
2.if i run any of sample code (with no call to gnome-terminal) it works fine with event of pluging.
3. if i run d.sh independentaly like
Code:
ivb@ivb-desktop:~$ ./d.sh
terminal gets open
4.but with link to udev .rule the d.sh script doent work fine the gnome-terminal never gets open

please kindly consider ma request n give solution and way to it.

Thanks & Regards
Rohan

Last edited by rohaanembedded; 05-27-2013 at 08:56 AM.
 
Old 05-27-2013, 09:01 AM   #2
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by rohaanembedded View Post
3. if i run d.sh like
Code:
ivb@ivb-desktop:~$ ./d.sh
terminal gets open
Rather than run your script as the current user that is logged into the system, try running it as another user (e.g. root).

If your system supports sudo, then try something like this:
Code:
$ sudo -i
<enter password>

# <path-to-script>/d.sh
What you will probably see is an error indicating that root user does not have permission to open the current display (which is in use by the regular user).

I would suggest that you plan an alternative to launching a terminal.
 
1 members found this post helpful.
Old 05-27-2013, 09:23 AM   #3
rohaanembedded
Member
 
Registered: May 2013
Location: India
Distribution: Ubuntu 11.10
Posts: 178

Original Poster
Rep: Reputation: Disabled
Question

Quote:
Originally Posted by dwhitney67 View Post
Rather than run your script as the current user that is logged into the system, try running it as another user (e.g. root).

If your system supports sudo, then try something like this:
Code:
$ sudo -i
<enter password>

# <path-to-script>/d.sh
What you will probably see is an error indicating that root user does not have permission to open the current display (which is in use by the regular user).

I would suggest that you plan an alternative to launching a terminal.

Dear sir,
Quote:
really Thanks for information is there any other way which can be used to open terminal n run code on that new terminal
please help me in this
Thanks & Regards
rohan
 
Old 05-27-2013, 09:55 AM   #4
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by rohaanembedded View Post
really Thanks for information is there any other way which can be used to open terminal n run code on that new terminal
You do not need to open a terminal to run code; if you are able to execute a shell script, then that should be sufficient.

If you are seeking user input, then you may need to rely on something other than gnome-terminal.

P.S. It would be helpful to know what is it that you want to do, not how you want to do it.

Last edited by dwhitney67; 05-27-2013 at 09:56 AM.
 
Old 05-27-2013, 11:56 AM   #5
rohaanembedded
Member
 
Registered: May 2013
Location: India
Distribution: Ubuntu 11.10
Posts: 178

Original Poster
Rep: Reputation: Disabled
Unhappy

Dear sir,

i have one usb device containing Cypress usb controller. i have developed one user space driver which does 4-5 fucntionalities like firmware download, getdescriptor(shows device descriptors), check_bus_speed, show_IDvendor,
this code i have developed using libusb and cyusb parent drivers (usb wrapper).
now i want ma device to have hot plug facility, that means whenever device is plugged in one terminal shud get opened and on that my developed code get executed automatically. and gives me options like press 1 for firware download 2. for this n 3. for this like interactive thing.
so i used .rule file (udev rules) for getting know that device is connect...
and what i am doing i have given in previous posts.

i am able to run code through script n get sum functionality on hot plug but i have to have interactive session where it ask me for options what i want to do
n here i am dnt knw wats going wrng terminal doesnt open.
so need one more option to make it happen or open the terminal

kindly consider ma request for help n do rply

thanks & Regards
rohan

Last edited by rohaanembedded; 05-27-2013 at 11:59 AM.
 
Old 05-27-2013, 01:41 PM   #6
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
You might be able to get away with using 'gksu' to launch a terminal. However if you invoke 'gksu' as root, then the terminal will also be launched with root privileges (and this would be a bad idea). To prevent this, you can use the -u option to specify the user who currently is owner of the system display.

In it's basic form, gksu can be used as follows:
Code:
gksu gnome-terminal
If you know the target user:
Code:
gksu -u <user> gnome-terminal
where <user> is the user-id.
 
1 members found this post helpful.
Old 05-28-2013, 12:14 AM   #7
rohaanembedded
Member
 
Registered: May 2013
Location: India
Distribution: Ubuntu 11.10
Posts: 178

Original Poster
Rep: Reputation: Disabled
Unhappy

Dear sir,

i tried that also but found no Luck!!!

Quote:
#!/bin/bash


gksu -u ivb gnome-terminal

exec /bin/bash
~
i tried this in d.sh
but terminal is still not opening on the hot plug event. my other code runs on hot plug. but code containg gnome-terminal doesnt work atall
how to get rid of this

thanks for your support sir,
please let me know about any solution

Regards
rohan
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] catching a hot plug event linux rohaanembedded Programming 10 05-24-2013 07:20 AM
Script to capture gnome-screensaver event doesn't work if run as root bubuntu Linux - General 3 01-22-2013 04:48 AM
Gnome at Fedora13: launch button for call of gnome-terminal to see script-output A_Birkert Linux - Desktop 1 11-07-2010 06:40 PM
[SOLVED] How to make a bash script keep running in same terminal after it calls second script? JohnRock Linux - Newbie 4 06-25-2010 09:16 AM
bash script to resize gnome terminal ? smoker Linux - General 1 03-17-2006 03:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration