Como faço pra conseguir imprimir na tela somente as informações que eu quero de um arquivo?
Segue o programa que preciso fazer:
Preciso de um programa em C que leia as linhas abaixo
de um arquivo e extraia as seguintes informacoes:
physmem
np
properties
jobs
a saída devera ser no formato de uma tabela
cpu physmem np properties jobs
taita143
state = job-exclusive
np = 4
properties = mem18,mem8,mem4
ntype = cluster
jobs = 0/3760.taita142.jb.br, 1/3760.taita142.jb.br, 2/3760.taita142.jb.br, 3/3760.taita142.jb.br
status = opsys=linux,uname=Linux taita143 2.6.32-5-amd64 #1 SMP Mon Jan 9 20:49:59 UTC 2012 x86_64,sessions=1570,nsessions=1,nusers=1,idletime=146138,totmem=22034816kb,availmem=21191024kb,physmem=16177544kb,ncpus=8,loadave=4.00,gres=,netload=19022850307,state=free,jobs=3760.taita142.jb.br,varattr=,rectime=1336134254
taita144
state = down
np = 4
properties = mem4,mem2
ntype = cluster
taita145
state = job-exclusive
np = 4
properties = mem18,mem8,mem4
ntype = cluster
jobs = 0/3809.taita142.jb.br, 1/3809.taita142.jb.br, 2/3809.taita142.jb.br, 3/3809.taita142.jb.br
status = opsys=linux,uname=Linux taita145 2.6.32-5-amd64 #1 SMP Mon Jan 9 20:49:59 UTC 2012 x86_64,sessions=4272,nsessions=1,nusers=1,idletime=151635,totmem=22035840kb,availmem=17572024kb,physmem=16177544kb,ncpus=8,loadave=4.01,gres=,netload=7084571313,state=free,jobs=3809.taita142.jb.br,varattr=,rectime=1336134253
taita146
state = job-exclusive
np = 4
properties = mem4,mem2,mem18,mem8
ntype = cluster
jobs = 0/3756.taita142.jb.br, 1/3756.taita142.jb.br, 2/3756.taita142.jb.br, 3/3756.taita142.jb.br
status = opsys=linux,uname=Linux taita146 2.6.32-5-amd64 #1 SMP Mon Jan 16 16:22:28 UTC 2012 x86_64,sessions=1507,nsessions=1,nusers=1,idletime=151635,totmem=22034420kb,availmem=15633076kb,physmem=16177152kb,ncpus=8,loadave=4.00,gres=,netload=23194452649,state=free,jobs=3756.taita142.jb.br,varattr=,rectime=1336134258
taita147
state = free
np = 4
properties = mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita147 2.6.26-2-amd64 #1 SMP Sun Jun 21 04:47:08 UTC 2009 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=151573,totmem=10159992kb,availmem=10075380kb,physmem=8200320kb,ncpus=4,loadave=0.00,gres=,netload=6785260445,state=free,jobs=,varattr=,rectime=1336134248
taita148
state = free
np = 4
properties = mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita148 2.6.26-2-amd64 #1 SMP Wed Aug 19 22:33:18 UTC 2009 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=66357,totmem=17967600kb,availmem=17903948kb,physmem=8200312kb,ncpus=4,loadave=0.00,gres=,netload=4477056,state=free,jobs=,varattr=,rectime=1336134263
taita141
state = down
np = 4
properties = mem8,mem4
ntype = cluster
taita150
state = free
np = 4
properties = mem8,mem18,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita150 2.6.26-2-amd64 #1 SMP Thu Nov 25 04:30:55 UTC 2010 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=144764,totmem=20310192kb,availmem=20239772kb,physmem=16406408kb,ncpus=8,loadave=0.00,gres=,netload=159081814,state=free,jobs=,varattr=,rectime=1336134258
taita149
state = free
np = 4
properties = mem18,mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita149 2.6.26-2-amd64 #1 SMP Thu Nov 25 04:30:55 UTC 2010 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=148175,totmem=20310192kb,availmem=20238628kb,physmem=16406408kb,ncpus=8,loadave=0.00,gres=,netload=158730084,state=free,jobs=,varattr=,rectime=1336134256
taita154
state = free
np = 4
properties = mem18,mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita154 2.6.26-2-amd64 #1 SMP Wed Sep 21 03:36:44 UTC 2011 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=145908,totmem=22049180kb,availmem=21976992kb,physmem=16193528kb,ncpus=8,loadave=0.00,gres=,netload=3228868,state=free,jobs=,varattr=,rectime=1336134255
taita155
state = down
np = 4
properties = mem18,mem8,mem4
ntype = cluster
taita156
state = free
np = 4
properties = mem18,mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita156 2.6.26-2-amd64 #1 SMP Wed Sep 21 03:36:44 UTC 2011 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=151637,totmem=22321168kb,availmem=22242788kb,physmem=16457752kb,ncpus=8,loadave=0.00,gres=,netload=5648258,state=free,jobs=,varattr=,rectime=1336134254
taita25
state = free
np = 4
properties = mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita25 2.6.35-32-generic #67-Ubuntu SMP Mon Mar 5 19:39:49 UTC 2012 x86_64,sessions=3407 3694 3698 3699 3707,nsessions=5,nusers=1,idletime=676703,totmem=13281084kb,availmem=12899792kb,physmem=8193344kb,ncpus=4,loadave=0.02,gres=,netload=5825908966,state=free,jobs=,varattr=,rectime=1336134289
taita19
state = down,job-exclusive
np = 4
properties = mem8,mem4
ntype = cluster
jobs = 0/3754.taita142.jb.br, 1/3754.taita142.jb.br, 2/3754.taita142.jb.br, 3/3754.taita142.jb.br
taita151
state = free
np = 8
properties = mem18,mem4,mem8
ntype = cluster
status = opsys=linux,uname=Linux taita151 2.6.26-2-amd64 #1 SMP Wed Aug 19 22:33:18 UTC 2009 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=151564,totmem=68014444kb,availmem=67666288kb,physmem=66054772kb,ncpus=16,loadave=0.00,gres=,netload=471260223,state=free,jobs=1634.taita142.jb.br,varattr=,rectime=1336134256
taita152
state = down
np = 8
properties = mem18,mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita152 2.6.26-2-amd64 #1 SMP Tue Jan 25 05:59:43 UTC 2011 x86_64,sessions=? 15201,nsessions=? 15201,nusers=0,idletime=120170,totmem=83629868kb,availmem=83432024kb,physmem=66054768kb,ncpus=16,loadave=0.00,gres=,netload=159982019,state=free,jobs=1506.taita142.jb.br,varattr=,rectime=1336102799
taita153
state = free
np = 8
properties = mem18,mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita153 2.6.26-2-amd64 #1 SMP Wed Sep 21 03:36:44 UTC 2011 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=126351,totmem=85597836kb,availmem=85398028kb,physmem=66054772kb,ncpus=16,loadave=0.00,gres=,netload=158882238,state=free,jobs=,varattr=,rectime=1336134256
Question
Thamara
Como faço pra conseguir imprimir na tela somente as informações que eu quero de um arquivo?
Segue o programa que preciso fazer:
Preciso de um programa em C que leia as linhas abaixo
de um arquivo e extraia as seguintes informacoes:
physmem
np
properties
jobs
a saída devera ser no formato de uma tabela
cpu physmem np properties jobs
taita143
state = job-exclusive
np = 4
properties = mem18,mem8,mem4
ntype = cluster
jobs = 0/3760.taita142.jb.br, 1/3760.taita142.jb.br, 2/3760.taita142.jb.br, 3/3760.taita142.jb.br
status = opsys=linux,uname=Linux taita143 2.6.32-5-amd64 #1 SMP Mon Jan 9 20:49:59 UTC 2012 x86_64,sessions=1570,nsessions=1,nusers=1,idletime=146138,totmem=22034816kb,availmem=21191024kb,physmem=16177544kb,ncpus=8,loadave=4.00,gres=,netload=19022850307,state=free,jobs=3760.taita142.jb.br,varattr=,rectime=1336134254
taita144
state = down
np = 4
properties = mem4,mem2
ntype = cluster
taita145
state = job-exclusive
np = 4
properties = mem18,mem8,mem4
ntype = cluster
jobs = 0/3809.taita142.jb.br, 1/3809.taita142.jb.br, 2/3809.taita142.jb.br, 3/3809.taita142.jb.br
status = opsys=linux,uname=Linux taita145 2.6.32-5-amd64 #1 SMP Mon Jan 9 20:49:59 UTC 2012 x86_64,sessions=4272,nsessions=1,nusers=1,idletime=151635,totmem=22035840kb,availmem=17572024kb,physmem=16177544kb,ncpus=8,loadave=4.01,gres=,netload=7084571313,state=free,jobs=3809.taita142.jb.br,varattr=,rectime=1336134253
taita146
state = job-exclusive
np = 4
properties = mem4,mem2,mem18,mem8
ntype = cluster
jobs = 0/3756.taita142.jb.br, 1/3756.taita142.jb.br, 2/3756.taita142.jb.br, 3/3756.taita142.jb.br
status = opsys=linux,uname=Linux taita146 2.6.32-5-amd64 #1 SMP Mon Jan 16 16:22:28 UTC 2012 x86_64,sessions=1507,nsessions=1,nusers=1,idletime=151635,totmem=22034420kb,availmem=15633076kb,physmem=16177152kb,ncpus=8,loadave=4.00,gres=,netload=23194452649,state=free,jobs=3756.taita142.jb.br,varattr=,rectime=1336134258
taita147
state = free
np = 4
properties = mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita147 2.6.26-2-amd64 #1 SMP Sun Jun 21 04:47:08 UTC 2009 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=151573,totmem=10159992kb,availmem=10075380kb,physmem=8200320kb,ncpus=4,loadave=0.00,gres=,netload=6785260445,state=free,jobs=,varattr=,rectime=1336134248
taita148
state = free
np = 4
properties = mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita148 2.6.26-2-amd64 #1 SMP Wed Aug 19 22:33:18 UTC 2009 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=66357,totmem=17967600kb,availmem=17903948kb,physmem=8200312kb,ncpus=4,loadave=0.00,gres=,netload=4477056,state=free,jobs=,varattr=,rectime=1336134263
taita141
state = down
np = 4
properties = mem8,mem4
ntype = cluster
taita150
state = free
np = 4
properties = mem8,mem18,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita150 2.6.26-2-amd64 #1 SMP Thu Nov 25 04:30:55 UTC 2010 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=144764,totmem=20310192kb,availmem=20239772kb,physmem=16406408kb,ncpus=8,loadave=0.00,gres=,netload=159081814,state=free,jobs=,varattr=,rectime=1336134258
taita149
state = free
np = 4
properties = mem18,mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita149 2.6.26-2-amd64 #1 SMP Thu Nov 25 04:30:55 UTC 2010 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=148175,totmem=20310192kb,availmem=20238628kb,physmem=16406408kb,ncpus=8,loadave=0.00,gres=,netload=158730084,state=free,jobs=,varattr=,rectime=1336134256
taita154
state = free
np = 4
properties = mem18,mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita154 2.6.26-2-amd64 #1 SMP Wed Sep 21 03:36:44 UTC 2011 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=145908,totmem=22049180kb,availmem=21976992kb,physmem=16193528kb,ncpus=8,loadave=0.00,gres=,netload=3228868,state=free,jobs=,varattr=,rectime=1336134255
taita155
state = down
np = 4
properties = mem18,mem8,mem4
ntype = cluster
taita156
state = free
np = 4
properties = mem18,mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita156 2.6.26-2-amd64 #1 SMP Wed Sep 21 03:36:44 UTC 2011 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=151637,totmem=22321168kb,availmem=22242788kb,physmem=16457752kb,ncpus=8,loadave=0.00,gres=,netload=5648258,state=free,jobs=,varattr=,rectime=1336134254
taita25
state = free
np = 4
properties = mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita25 2.6.35-32-generic #67-Ubuntu SMP Mon Mar 5 19:39:49 UTC 2012 x86_64,sessions=3407 3694 3698 3699 3707,nsessions=5,nusers=1,idletime=676703,totmem=13281084kb,availmem=12899792kb,physmem=8193344kb,ncpus=4,loadave=0.02,gres=,netload=5825908966,state=free,jobs=,varattr=,rectime=1336134289
taita19
state = down,job-exclusive
np = 4
properties = mem8,mem4
ntype = cluster
jobs = 0/3754.taita142.jb.br, 1/3754.taita142.jb.br, 2/3754.taita142.jb.br, 3/3754.taita142.jb.br
taita151
state = free
np = 8
properties = mem18,mem4,mem8
ntype = cluster
status = opsys=linux,uname=Linux taita151 2.6.26-2-amd64 #1 SMP Wed Aug 19 22:33:18 UTC 2009 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=151564,totmem=68014444kb,availmem=67666288kb,physmem=66054772kb,ncpus=16,loadave=0.00,gres=,netload=471260223,state=free,jobs=1634.taita142.jb.br,varattr=,rectime=1336134256
taita152
state = down
np = 8
properties = mem18,mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita152 2.6.26-2-amd64 #1 SMP Tue Jan 25 05:59:43 UTC 2011 x86_64,sessions=? 15201,nsessions=? 15201,nusers=0,idletime=120170,totmem=83629868kb,availmem=83432024kb,physmem=66054768kb,ncpus=16,loadave=0.00,gres=,netload=159982019,state=free,jobs=1506.taita142.jb.br,varattr=,rectime=1336102799
taita153
state = free
np = 8
properties = mem18,mem8,mem4
ntype = cluster
status = opsys=linux,uname=Linux taita153 2.6.26-2-amd64 #1 SMP Wed Sep 21 03:36:44 UTC 2011 x86_64,sessions=? 15203,nsessions=? 15203,nusers=0,idletime=126351,totmem=85597836kb,availmem=85398028kb,physmem=66054772kb,ncpus=16,loadave=0.00,gres=,netload=158882238,state=free,jobs=,varattr=,rectime=1336134256
Link to comment
Share on other sites
0 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.