Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How would I set my curl statement so that it puts the value of each $3 in for the username, and the value of each $4 for the wallclock information?

Some further information

I am trying to take the username and wallclock information and curl it into a system admin app on a website. Here is what I have so far

~/qacct.monthly | awk '{print $3}''{print $4}'

Yields this output: (where $3 = owner and $4 = wallclock)

    OWNER
WALLCLOCK
===================================================================

adeluca
1610
athardin
1
axelsone
18707336
bfinley
1875
bihe
9918667
brogers
108710282
ckbui
10
ctokheim
2445
dliang
6470745
gaolong
3395364
htrn
1
jchen12
13475380
jdereus
1086617
jiangp
24343174
jinkwang
30733663
johnsonhj
58967432
joneskl
32085365
jongkwki
47160388
jwpark
101601184
keefeh
2
ktan
13484388
litd
2031229
lteng
3882281
luhon
32500508
lvantol
66959
lwen
1272867
mama
4635850
mariettaj
44247412
msscully
64419431
nkumr
6
piersonr
454978875
rhylock
187877
rjconnel
57
root
65
sbonett
2388132
shishen
114025934
tbair
1363490
tnath
9196673
wanj
53041427
wassinkt
376268
wdeng
949336
wpmcdowe
5360475
zeiene
159442263
zhaok
3609429

Here is my curl statement:

curl -d 'cluster=<CLUSTER>&username=<USER>&wallclock=<WALLCLOCK>' \
    'https://www-dev.****.****.edu/****SysAdmin/****sysadmin/clusterusage/rest/update.html'; 
share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

I assume "qacct.monthly" prints 2 header lines which you don't want:

url='https://www-dev...'
cluster=CLUSTER # or whatever
~/qacct.monthly | awk 'NR > 2 {print $3, $4}' | while read owner clock; do
  curl -d "cluster=${cluster}&username=${owner}&wallclock=${clock}" "$url" 
done
share|improve this answer
    
works like a charm glenn, thanks I really appreciate it! –  Jeff Mar 29 '12 at 18:51
add comment

You can make awk execute curl. Assuming that the cluster name nd the user and wallclock fields don't contain any shell special character:

~/qacct.monthly | awk -v cluster='somename' 'NR > 2 {
    system "curl -d 'cluster=" cluster "&username=" $3 "&wallclock=" $4 "' "
           "'https://www-dev.****.****.edu/****SysAdmin/****sysadmin/clusterusage/rest/update.html'"
}'

Alternatively, you can do all the processing in the shell.

cluster='somename'
~/qacct.monthly | tail -n +3 |
while read -r header sep owner wallclock rest; do
  curl -d "$cluster&username=$owner&wallclock=$wallclock" \
    'https://www-dev.****.****.edu/****SysAdmin/****sysadmin/clusterusage/rest/update.html'
done
share|improve this answer
add comment
~/qacct.monthly | awk '{print "curl -d '\''cluster=<CLUSTER>&username=<"$3">&wallclock=<"$4">'\''  '\''https://www-dev.****.****.edu/****SysAdmin/****sysadmin/clusterusage/rest/update.html'\''"}'
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.