Trouble with setting a variable with vastool

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Trouble with setting a variable with vastool
# 1  
Old 08-10-2015
Trouble with setting a variable with vastool

Hi I have this command that when put on the command line it returns the output the way I want it.

/opt/quest/bin/vastool list -a groups | grep testdev_li | grep dev | awk -F"[D:]" 'NF>2{print $2}' | cut -c2- | tr '\n' '|'

The output of this is


but when i try to set this to a variable, it gives me an error

tst=/opt/quest/bin/vastool list -a groups | grep abinitio_bi | grep developers | awk -F"[D:]" 'NF>2{print $2}' | cut -c2- | tr '\n' '|'

The error is this(name of the file is test.ksh)

test.ksh: line 3: list: not found

im kinda new to shell scripting so im not sure what to do
# 2  
Old 08-10-2015
You need to use command substitution:

This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 08-10-2015
I'd be surprised if grep dev would do anything after the grep testdev_li, and both could be incorporated into the awk command. Try
tst=$(/opt/quest/bin/vastool list -a groups | awk -F"[D:]" -vOFS="|" '/developers/ && /abinitio_bi/ && NF > 2 {print substr ($2,2)}')

If need be, add an END {printf "\n"} section.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Linux

Trouble setting up basic user authentication on apache2 web server

Hey guys! So I decided to set up some basic user authentication on my apache2 server, and I am running into some problems. I followed the documentation provided by apache on their website, but I cant create the password file for some reason. I did a little trouble shooting myself, and found... (40 Replies)
Discussion started by: LinuxIntern445
40 Replies

2. UNIX for Dummies Questions & Answers

Trouble setting up a shared folder

I'm trying to set up a folder in my home directory that will be shared with another user but for some reason it is not working this is what I've done, I have tried two different ways using ACL's and chown/chgrp etc I set up a group called say: sharedgroup and added both my user (john) and fred... (3 Replies)
Discussion started by: 14952john
3 Replies

3. Shell Programming and Scripting

Trouble setting up flag ( getopt) for my script

do case $option in d ) CHEC=true;; # more option processing can go here \? ) echo "Unknown option: -$OPTARG" : ) echo "Missing option argument for -$OPTARG";; * ) echo "Unimplimented option: -$OPTARG";; esac done shift $(($OPTIND - 1)) (2 Replies)
Discussion started by: upenmishra
2 Replies

4. Shell Programming and Scripting

Trouble with passing variable to sed

Here is my code #!/bin/bash username=gnowicki sed '$s/$/ $username/' < sshd_config 1 <> sshd_config what this is supposed to do is take the name gnowicki and put it at the end of the last line of the sshd_config and it works except not using the variable, if I put the name "gnowicki" where... (2 Replies)
Discussion started by: slufoot80
2 Replies

5. Shell Programming and Scripting

Having trouble greping a variable

I'm trying to take a users input, and then such a text file to see if it contains it. I get an error when running it: "./ Line 8: echo Username read username if ; then echo Login successful. else echo Failed to login. fi If someone could give me some input to where I'm... (4 Replies)
Discussion started by: Hegarz
4 Replies

6. UNIX for Dummies Questions & Answers

Trouble Setting Up Sun Ultra 10 - Displaying Garbage

Hello there, I am new to this forum as well as to the UNIX world. Recently graduated with a degree in Computing and just started learning UNIX & bought 3 Sun Ultra 10 Servers. I was trying to set the Servers up so I can use them; the Servers don't have a VGA card. My laptop, which I would be... (6 Replies)
Discussion started by: frhan2u
6 Replies

7. Ubuntu

Trouble setting up Java classpath

Saw an error while setting up an application called i2phex: # ./ java.lang.RuntimeException: Failed to initialize at phex.common.ManagerController.initializeManagers( at phex.Main.main( (0 Replies)
Discussion started by: Israel213
0 Replies

8. IP Networking

Trouble setting up a static IP on NetGear DGN1000

I have been trying to setup a static ip, however everytime I do so my internet disconnects and won't connect untill I switch back to dynamic. My router is a NetGear DGN1000 and I'm using it wired. Could anyone help? (0 Replies)
Discussion started by: zomigosh
0 Replies

9. Shell Programming and Scripting

Trouble saving variable

Hi, I have problems when you save a variable of a command. I have put the following line: CONEXION_BAGDAD = $ (grep-c "Please login with USER and PASS" $ LOG_FILE_BAGDAD) But I returned the following error: syntax error at line 67: `CONEXION_BAGDAD = $ 'unexpected Because it can happen?... (2 Replies)
Discussion started by: danietepa
2 Replies
Login or Register to Ask a Question

Featured Tech Videos