Visit Our UNIX and Linux User Community

Setting array equal to command response

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Setting array equal to command response
# 1  
Old 07-19-2008
Setting array equal to command response

normally when i type:
condor_q | tail -1
command line returns:
0 jobs; 0 idle, 0 running, 0 held

I want use the number in front of 'running' in a series of equality tests to submit more jobs when my queue gets low. Someone showed me how to do it a few days ago by setting an array equal to the command. I thought it was:

set qu = ( condor_q | tail -1 )

But this is not working..... any ideas?
# 2  
Old 07-19-2008
i think may be use
set qu=($(condor_q|tail -1))

i test the statement in bash:
$ ls                    hsperfdata_root         https-admserv-9d93b4d6

$ arr=( $(ls))
$ echo ${#arr[@]}
$echo ${arr[0]}

# 3  
Old 07-19-2008
That one returns:

Illegal variable name.
# 4  
Old 07-20-2008
Try this:

qu=`condor_q | tail -1 | cut -d" " -f 5`


qu=`condor_q | tail -1 | awk '{print $5}'`

# 5  
Old 07-20-2008
they both work... thank you very much

Previous Thread | Next Thread
Test Your Knowledge in Computers #31
Difficulty: Easy
Alan Turing was the founder of IBM.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - setting fs to equal any single character

Hi Does anyone know how to set any character as the field separator with awk/nawk on a solaris 10 box. I have tried using /./ regex but this doesnt work either and im out of ideas. thanks (7 Replies)
Discussion started by: chronics
7 Replies

2. Shell Programming and Scripting

perl, put one array into many array when field is equal to sth

Hi Everyone, #!/usr/bin/perl use strict; use warnings; my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d"); would like to split the @test array into two array: @test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d"); means search for 3rd filed. Thanks find the... (0 Replies)
Discussion started by: jimmy_y
0 Replies

3. HP-UX

max limit in in setting array

hi, iam getting error when i assign a variable to an array of more that 315 character in length set -A array <variable> <variable> value is 000001 000002 and up to 000045 it is giving error as "The specified subscript cannot be greater than 1024." can any one help me to solve this (2 Replies)
Discussion started by: gomathi
2 Replies

4. Shell Programming and Scripting

scp command and no response

I should trasfer some files by to local host. In order to check the function works i tried to transfer a single file and I typed: scp -P 21 /filename.nas At this point i haven't response anch i have to type CTRL+C to return to... (2 Replies)
Discussion started by: andreac81
2 Replies

5. UNIX for Dummies Questions & Answers

'less' command response is garbled

Helo , I m using RHEL 4. If I run 'ls -laF | more', response is properly display. but when I run If I run 'ls -laF | less', the response is garbled what to do to remove this? Regards, Amit (4 Replies)
Discussion started by: amitpansuria
4 Replies

6. Shell Programming and Scripting

dynamically setting an array

Hi Gurus, How do I dynamically set up an array. Below is my code if ] then set ecomm_task_limit = '${ecomm_srvr}' fi Here, I want to set values in the array "${ecomm_srvr}" into ecomm_task_limit upon each iteration. Finally I want to display all the values in the new array... (4 Replies)
Discussion started by: ragha81
4 Replies

7. UNIX for Dummies Questions & Answers

Help - Setting variables equal to data from another file

Relatively new poster but long time reader. I tried searching all threads for similar situations with mine but I've had no luck with some of the solutions. I have a script (script.ksh) that is getting information from an Oracle DB and spooling it into a text file (log.txt). I would then like... (1 Reply)
Discussion started by: Crios121
1 Replies

8. Shell Programming and Scripting

Setting values in an array? Easy one

I need to do something like this: KEYS= for key in $KEYS do echo $key done The KEYS are static values in my script, I'm just having trouble with setting them as separate values. Thanks! (3 Replies)
Discussion started by: TheCrunge
3 Replies

9. UNIX for Advanced & Expert Users

Command to list Files less than or equal to 2k size

Hi, *.xml files stored on date wise folders. I need to extract *.xml files from all the folders. File size is lessthan or equal to 2K. Please let me know command or some shell program to due this job on linux m/c This is urgent, Thanks in advance - Bache Gowda (3 Replies)
Discussion started by: bache_gowda
3 Replies

10. Programming

equal command for gotoxy() in uinx

hello i am new user to this site. i want to know about equal command for gotoxy() which is used in dos operating system and also equal hedder file for conio.h? please give me responce to me if anybudy know about that. (5 Replies)
Discussion started by: g_s_r_c
5 Replies

Featured Tech Videos