LinuxQuestions.org
Help answer threads with 0 replies.
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 12-03-2006, 12:52 PM   #1
wmcase
Member
 
Registered: Sep 2003
Location: Ottawa, Ontario, Canada
Distribution: Fedora 12
Posts: 57

Rep: Reputation: 15
Brain cramp using zenity in script ??


Hi;

I have obviously missed something.

I am using 'zenity --entry' in a script. I want to capture within my script the value that I have input in the zenity input screen/block.

How do I do that? Are they the same as Bash parameters?
I.E. Are they positional parameters or $? or $# or $*?

I have read the manual examples and ny google tutorials carefully and I can't see how this might be done.

For those interested my script is the following:

#! /bin/bash
# Open nautilus as root
# file name: RootBrowse
# zenity --info \
# --text="$?"


sudo -K
zenity --entry \
--title="Browse files as root" \
--text="Enter your _password:" \
--entry-text "" \
--hide-text | sudo -S nautilus --no-desktop --browser \
1> /dev/null 2> /dev/null

if [ "$?" != 0 ]; then
zenity --error --text="Sorry, wrong password"
exit 1
fi

# End

My problem is that this script runs fine from the gterminal command line, but always tells me I have a wrong password when run from a panel/desktop launcher or the nautilus-script right click menu.

But still, I would be happy just knowing how to capture the zenity input value.

All suggestions gratefully received.

I am using Fedora Core 6 and Gnome 2.16.0.
 
Old 12-03-2006, 02:05 PM   #2
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 735

Rep: Reputation: 76
Hi.

In a small sample:
Code:
#!/bin/sh

# @(#) s2       Demonstrate capture of entered text.

VERSION=$( zenity --version )
echo " Zenity version is :$VERSION:"

NAME=$( zenity   --title  "Entry box for name" --entry --text \
"What is your name?" )

echo " Variable NAME is :$NAME:"
which follows the man page note for the second example:
Quote:
... The entered text is returned on standard output.
The example produces, after a name has been entered:
Code:
% ./s2
 Zenity version is :2.8.2:
 Variable NAME is :Bill Case:
Best wishes ... cheers, makyo
 
Old 12-03-2006, 02:20 PM   #3
wmcase
Member
 
Registered: Sep 2003
Location: Ottawa, Ontario, Canada
Distribution: Fedora 12
Posts: 57

Original Poster
Rep: Reputation: 15
Thanks mayko;

Resolved with a big sigh of relief and a huge slap on the forehead. "Of course"

Quote:
NAME=$( zenity --title "Entry box for name" --entry --text \
"What is your name?" )
I wasn't writing the variable syntax properly and I know better.
 
  


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
192.168.* all internet? Script error? Brain dead. kevin9 Linux - Networking 3 10-21-2005 05:49 PM
Linux in Brain Surgery rvijay Linux - News 4 07-22-2005 06:27 PM
Problem with combining bash with zenity --progress chii-chan Programming 2 05-06-2005 03:12 AM
Brian cramp with shell script for loops SheldonPlankton Programming 4 07-16-2004 06:45 AM
help! my brain is melting! briancof Linux - Newbie 5 11-26-2001 03:35 PM

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

All times are GMT -5. The time now is 06:18 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