Help with making the output of a command a variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with making the output of a command a variable
# 1  
Old 04-30-2019
Help with making the output of a command a variable

I'm writing a script that goes something like this:

Code:
#!/bin/bash

zenity --list --checklist --title="Choose Packages to Install" --width="1000" --height="400" \
--column="Select" --column="Package Name" --column="Description" \
GIMP=$( " " GIMP "GIMP is a free and open source photo editor."  \ )
if [ $GIMP == "GIMP" ]
then 
	sudo apt-get install $GIMP
fi

I want to open a dialog box with check boxes, package names, and descriptions. The box I have written is the first attached file.

I plan on adding other programs, but I have not gotten there yet.

The
Code:
" "

in the line
Code:
" " GIMP "Known as GIMP, GNU Image Manipulation Program is a free and open source photo editor." \

is for the first checkbox.

My main problem is the quotation marks at the end and beginning of the line (attached file #2). The quotation marks read in the wrong direction, and not how I want them to, having quotation marks inside of quotation marks?

Is there any way to fix this? Do I need to take a completely different approach?
Help with making the output of a command a variable-dialogbox10png
Help with making the output of a command a variable-zenity1png

Last edited by Defunct_Lizard; 04-30-2019 at 10:15 PM.. Reason: I did not intend for the attached files not to be alongside the text.
# 2  
Old 05-01-2019
I am not a fan of zenity, but I don't think zenity or double-quotes are your problem here.

The $( in your bash script starts a command substitution. That command substitution tries to run the command named by the first argument in the command substitution (in this case, a command named by the double-quoted <space> character that you say is intended to give you a check box). I would expect that to give you an error something like:
Code:
bash:  : command not found

but you won't get that until you finish the command substitution. Your command substitution is looking for an unescaped closing parenthesis to finish it. Since you have a backslash character escaping the closing parenthesis in your command substitution, another closing parenthesis is needed to close the command substitution!

Why are you trying to use a command substitution here? What command are you trying to run in this command substitution?
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get the output of a ISQL command in a variable?

I am trying to run a query which returns a sum value(a number). I want to get it in a variable so that i can refer to that variable in different places. when i am running the following command variable=`isql -Uuser -Sserver -Ppassword 1> select sum(count(*)) from xyz..abc where clm_id... (2 Replies)
Discussion started by: Sharma331
2 Replies

2. UNIX for Advanced & Expert Users

ls output into a read command as a variable

I'm working on a short BASH script on my Ubuntu box that will run powerpoint scripts with MS Powerpoint Viewer 2007 via WINE. I can run the presentation when I run it manually but what i'd like to do is have the script look for the newest file then run it. #! /bin/sh # Start the newest... (2 Replies)
Discussion started by: binary-ninja
2 Replies

3. Shell Programming and Scripting

how to save an output of a command in a variable

Hi, in shell script, i have the command swstart -p which returns an output. i want to store the output of this command into a variable. how i can do that excerpt from the script #!/usr/bin/ksh # # # # Program: swstart -p # # Description: Starts the sentinels on Slave server ... (4 Replies)
Discussion started by: lookinginfo
4 Replies

4. Shell Programming and Scripting

Making script show command (e.g. copy) being executed and variable substitution?

When script is running you only see when some of the commands are not successfull. Is there a way to see which command are executed and to show the substitution of variables as every line is executed ? (3 Replies)
Discussion started by: gr0124
3 Replies

5. Shell Programming and Scripting

How to put output of one command into a variable

Hi, Let say I have these 3 files (state, list and myscript). I want to be able get the sample output like below when I run myscript. Any one know how to fix the code? TIA. ~~~~~~~~~~~~~~~ > cat /home/state CA > cat /home/list CA 100 50 20 AUS 120 61 10 > cat myscript... (6 Replies)
Discussion started by: joker_789us
6 Replies

6. Programming

Command output into a variable

Hi, with this command: cu -l /dev/ttyACM0 -s 9600 > name.txt I put the output of the port in a txt Is posible to do the same (or similar) in a var directly, inside a C program? cu -l /dev/ttyACM0 -s 9600 > variable ? I have trying this withs pipes, but i dont know how to... (6 Replies)
Discussion started by: daaran
6 Replies

7. Shell Programming and Scripting

Assigning output of a command to variable

When I run time -p <command>, it outputs: real X.XX user X.XX sys X.XXwhere X.XX is seconds. How I can take just that first number output, the seconds of real time, and assign that to a variable? (9 Replies)
Discussion started by: jeriryan87
9 Replies

8. Shell Programming and Scripting

get characters from output of a command in a variable

Hi, i have two questions, I am new to programming 1. I have an output of a command and i want to get some specific part of it in a variable. i am trying sr=`some comand xyz| grep 'Last Changed Rev:' | cut -c19-` now variable sr gets a end of line character at end. output of the command... (3 Replies)
Discussion started by: muaz
3 Replies

9. UNIX for Dummies Questions & Answers

redirect command output to variable

Hi, I am looking for a way to redirect the result from a command into a variable. This is the scenario. Using the find command I will be getting multiple records/lines back. Here is the command I am using: find /”path”/ -name nohup.out -print This now is giving me the paths and file... (1 Reply)
Discussion started by: hugow
1 Replies

10. Shell Programming and Scripting

Command output to a variable.

With cut -c 8-13 myfile, I am getting some numeric value. In my shell script I am trying to assign something like this, var=cut -c 8-13 myfile But at the time of execution I am getting -c is not found. If I dont assign, then script executes well. Can we not simply use the value from one... (8 Replies)
Discussion started by: videsh77
8 Replies
Login or Register to Ask a Question