Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Didattica > Corsi N - Z > Sistemi operativi I > Esame di laboratorio (Giugno 2007) - Domande Thread Rating: 3 votes, 5.00 average.
Pages (39): « First ... « 10 11 12 13 [14] 15 16 17 18 » ... Last »   Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
marcolino78
.simpatizzante.

User info:
Registered: Jun 2004
Posts: 11 (0.00 al dì)
Location:
Corso:
Anno:
Time Online: 14:02:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
altro esercizietto

ciao a tutti, vi sottopongo un'altro esercizietto che ho sentito:

creare 10 nuovi utenti prendendoli da un file di testo???

idee???

come si a passare i valori presi da un file di testo???

24-09-2007 09:58
Click Here to See the Profile for marcolino78 Click here to Send marcolino78 a Private Message Find more posts by marcolino78 Add marcolino78 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
jeremy.1983
allinuxato

User info:
Registered: Sep 2006
Posts: 42 (0.01 al dì)
Location: Saronno
Corso: Informatica
Anno: no comment
Time Online: 19:30:58 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Questa domanda era già stata risolta sul sito del corso ma lì è un un po' un casino, ti consiglio piuttosto di guardare QUI .

Le estensioni hanno poco significato in minix: quindi se tu crei user.list o user.txt non cambia nulla.

Se usi lo script devi lanciarlo così:

<nomescript> <nomefilelistautenti>

Ciao

24-09-2007 10:42
Click Here to See the Profile for jeremy.1983 Click here to Send jeremy.1983 a Private Message Find more posts by jeremy.1983 Add jeremy.1983 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
jeremy.1983
allinuxato

User info:
Registered: Sep 2006
Posts: 42 (0.01 al dì)
Location: Saronno
Corso: Informatica
Anno: no comment
Time Online: 19:30:58 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Re: Re: domandina

Originally posted by Bennyk
Sei sicuro di questa domanda? Su Linux non sarebbe un problema ma i comandi di MINIX sono molto limitati, io non ne sono ancora venuto a capo.
Qualcuno ha idee?


Ho fatto uno script, pensando di replicare la directory "/bin"

code:
#! /bin/sh cpdir -pr /bin /bin2 rm $(find /bin2 -type f)


Ciao

24-09-2007 11:20
Click Here to See the Profile for jeremy.1983 Click here to Send jeremy.1983 a Private Message Find more posts by jeremy.1983 Add jeremy.1983 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
banjoo
state bboni!!!

User info:
Registered: Oct 2005
Posts: 19 (0.00 al dì)
Location:
Corso: Informatica
Anno: 2
Time Online: 15:20:05: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Dimensione totale dei file per utente

Ciao, secondo voi può andar bene una cosa del genere per trovare l'occupazione totale per un utente?

#!/bin/sh
for NUM in $( find / -type f -user UTENTE | xargs du -s | cut -f 1); do
COUNT=$( expr $COUNT + $NUM)
done
echo "Totale: $COUNT"

a me sembra funzionare....
l'unica cosa, come faccio ad inserire l'utente come parametro quando lancio lo script? E' una cosa fattibile?

Grazie.

24-09-2007 14:06
Click Here to See the Profile for banjoo Click here to Send banjoo a Private Message Find more posts by banjoo Add banjoo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Bennyk
.amico.

User info:
Registered: Oct 2003
Posts: 38 (0.00 al dì)
Location: Milano
Corso: Informatica
Anno: ...
Time Online: 1 Day, 1:36:08: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Re: Re: Re: domandina

Originally posted by jeremy.1983
Ho fatto uno script, pensando di replicare la directory "/bin"[...]


Io ho provato così e sembra funzionare, certo non è proprio immediato...

code:
#!bin/sh if [ $# -lt 2 ]; then echo “syntax: $0 path1 path2 exit 1 fi echo “Copying folders...” find $1 -type d | sort | while read $DIR; do mkdir -p $2/$DIR chmod $(stat -mode $DIR | cut -d ',' -f 1) $2/$DIR done echo “Finished copying.” exit 0

24-09-2007 23:25
Click Here to See the Profile for Bennyk Click here to Send Bennyk a Private Message Find more posts by Bennyk Add Bennyk to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Bennyk
.amico.

User info:
Registered: Oct 2003
Posts: 38 (0.00 al dì)
Location: Milano
Corso: Informatica
Anno: ...
Time Online: 1 Day, 1:36:08: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Re: Dimensione totale dei file per utente

Originally posted by banjoo
Ciao, secondo voi può andar bene una cosa del genere per trovare l'occupazione totale per un utente?

[...]

a me sembra funzionare....
l'unica cosa, come faccio ad inserire l'utente come parametro quando lancio lo script? E' una cosa fattibile?


Per inserire l'utente come parametro ti basta usare $1 (i parametri che passi sulla riga di comando sono numerati $1, $2... $n. $0 è il nome del file chiamato).

Inoltre consiglio vivamente di usare il while, invece del for, per evitare errori di "Out of space" nella command substitution, specialmente in casi tipo: $(find / ...).

Trovate qualche esempio QUI

code:
#!bin/sh if [ $# -lt 1 ]; then echo “syntax: $0 userID exit 1 fi find / -type f -user $1 | xargs du -s | cut -f 1 | while read $NUM; do ...

24-09-2007 23:46
Click Here to See the Profile for Bennyk Click here to Send Bennyk a Private Message Find more posts by Bennyk Add Bennyk to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
marcolino78
.simpatizzante.

User info:
Registered: Jun 2004
Posts: 11 (0.00 al dì)
Location:
Corso:
Anno:
Time Online: 14:02:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
X jeremy.1983

sono andato a vedere la pagina che mi hai indicato e in effetti lo script non è complicato

1) #!/bin/bash
2) NUM=$(cat $1 | wc -l)
3) COUNT=0
4) while [ $NUM -ne $COUNT ]; do
5) COUNT=$(expr $COUNT + 1)
6) adduser $(cat $1 | awk "NR == $COUNT")
7) done

l'unica cosa che non ho capito è il $1, mi spiego meglio:
se per esempio chiamo il mio script NuovoUtente e il file FileUtenti.txt, come faccio a lanciarlo per far si che il cat $1 prenda come parametro il mio file???

forse cosi:
./NuovoUtente FileUtenti.txt

oppure manca qualcosa?
Grazie.

25-09-2007 10:54
Click Here to See the Profile for marcolino78 Click here to Send marcolino78 a Private Message Find more posts by marcolino78 Add marcolino78 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Peach
.amico.

User info:
Registered: Jun 2007
Posts: 22 (0.00 al dì)
Location: Milano
Corso: Informatica triennale
Anno: 1^ fuori corso
Time Online: 7:13:54 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Io faccio ./ nome script ma dice no such file or directory,ma se faccio find - type f lo trovo....come mai?????

25-09-2007 14:51
Click Here to See the Profile for Peach Click here to Send Peach a Private Message Find more posts by Peach Add Peach to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
banjoo
state bboni!!!

User info:
Registered: Oct 2005
Posts: 19 (0.00 al dì)
Location:
Corso: Informatica
Anno: 2
Time Online: 15:20:05: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Prova così, facendo attenzione agli spazi:

./NOMESCRIPT NOMEFILE

io personalmente non ho provato a dare estensione .txt al file di testo, ma questo non dovrebbe influire.

Attenzione anche alla directory in cui ti trovi al momento dell'esecuzione.

25-09-2007 16:26
Click Here to See the Profile for banjoo Click here to Send banjoo a Private Message Find more posts by banjoo Add banjoo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Peach
.amico.

User info:
Registered: Jun 2007
Posts: 22 (0.00 al dì)
Location: Milano
Corso: Informatica triennale
Anno: 1^ fuori corso
Time Online: 7:13:54 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

allora

io creo il mio file con elvis (ad esempio nfile)
poi faccio chmod +x nfile
e se faccio ./ nfile mi dice no such file or directory
ma se faccio . /root/nfile funziona....

Come faccio a sapere la directory in cui sto eseguendo?

25-09-2007 16:39
Click Here to See the Profile for Peach Click here to Send Peach a Private Message Find more posts by Peach Add Peach to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
imperator
.consigliere.

User info:
Registered: Apr 2004
Posts: 146 (0.02 al dì)
Location:
Corso:
Anno:
Time Online: 5 Days, 6:58:26 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

basta lanciare il comando pwd

25-09-2007 16:46
Click Here to See the Profile for imperator Click here to Send imperator a Private Message Find more posts by imperator Add imperator to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Peach
.amico.

User info:
Registered: Jun 2007
Posts: 22 (0.00 al dì)
Location: Milano
Corso: Informatica triennale
Anno: 1^ fuori corso
Time Online: 7:13:54 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

ok e se non sto eseguendo su root cosa faccio?

25-09-2007 16:50
Click Here to See the Profile for Peach Click here to Send Peach a Private Message Find more posts by Peach Add Peach to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Assochespasso
.novellino.

User info:
Registered: Sep 2007
Posts: 3 (0.00 al dì)
Location:
Corso:
Anno:
Time Online: 5:12:16 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Bennyk
Ciao a tutti,
aggiungo un'altra domanda fatta all'esame:

- Quali e quante estensioni ci sono nel sistema?
(per estensioni si intende qualsiasi cosa ci sia dopo il carattere “.”, es: archivio.gz)

La soluzione è questa:

find / | rev | cut -f 1 -d '.' | grep -v / | rev | sort | uniq -c | sort -n

Spiegazione:

find / trova tutto (files e directories) a partire dalla root dir
rev inverte ogni riga dell'output
cut -f 1 -d '.' estrae il primo campo di ogni riga usando il . come separatore
grep -v / eliminazione delle sole directories
rev inverte di nuovo ogni riga dell'output
sort ordina l'output
uniq -c elimina righe duplicate contandole, ora l'output è del tipo 123 gz
sort -n (non necessario) ordina i risultati numericamente

Nota:
Si può evitare il grep -v / usando cut -f 1 -d '.' -s.


Okkio che così trovi anche tutte le cartelle e file nascosti ( del tipo .cartella o .file).
Ho fatto uno script simile al tuo, escludendo cartelle e file nascosti:

find / -type f -name *.* | tr -s '/' ' ' | rev | cut -d ' ' -f 1 | rev | grep -v "^\." | rev | cut -d '.' -f 1 -s | rev | sort | uniq -c

find / -type f -name *.* cerco tutti i file che contengono un punto nel nome del file (i file trovati sono completi di path ad es. /root/prova/file)
tr -s '/' ' ' spazi al posto di /
rev stampo il nome del file al contrario
cut -d ' ' -f 1 estraggo il primo campo (è il nome del file al contrario). In questo modo ho il nome del file senza path
rev ristampo il nome del file "dritto"
grep -v "^\." escludo tutti i file che INIZIANO con un punto (sono quelli nascosti)
rev non lo ripeto più
cut -d '.' -f 1 -s estraggo il primo campo. Così ho l'estensione del file
rev
sort ordino le estensioni in ordine alfabetico, così posso eliminare le ripetizioni con uniq
uniq -c per ogni estensione ho il numero di ripetizioni

26-09-2007 08:47
Click Here to See the Profile for Assochespasso Click here to Send Assochespasso a Private Message Find more posts by Assochespasso Add Assochespasso to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
bog86
.consigliere.

User info:
Registered: Jan 2006
Posts: 117 (0.02 al dì)
Location:
Corso: Informatica
Anno: 3
Time Online: 1 Day, 23:03:56 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Peach
allora

io creo il mio file con elvis (ad esempio nfile)
poi faccio chmod +x nfile
e se faccio ./ nfile mi dice no such file or directory
ma se faccio . /root/nfile funziona....

Come faccio a sapere la directory in cui sto eseguendo?

Non mi funziona in nessuno modo! con . /root/nfile si impalla, con ./nfile nomi.txt dice no such file or directory...
come si fa allora?? help!!!!!

26-09-2007 09:36
Click Here to See the Profile for bog86 Click here to Send bog86 a Private Message Find more posts by bog86 Add bog86 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Bennyk
.amico.

User info:
Registered: Oct 2003
Posts: 38 (0.00 al dì)
Location: Milano
Corso: Informatica
Anno: ...
Time Online: 1 Day, 1:36:08: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Assochespasso
Okkio che così trovi anche tutte le cartelle e file nascosti ( del tipo .cartella o .file).
Ho fatto uno script simile al tuo, escludendo cartelle e file nascosti:

find / -type f -name *.* | tr -s '/' ' ' | rev | cut -d ' ' -f 1 | rev | grep -v "^\." | rev | cut -d '.' -f 1 -s | rev | sort | uniq -c

...


Si, avevo notato questo side effect ed ho provato con un altro script:

code:
find / | while read i; do basename $i; done | grep -v “^\.” |rev| cut -f 1 -d '.' -s |rev|sort|uniq -c|sort -nr


Ottima la tua soluzione con il triplo rev!

La domanda però, non era limitata ai soli files, ma qualsiasi estensione nel file system, anche eventuali cartelle tipo: cartella.ext (un pò insolito ma non impossibile).
Per questo io non uso -type f.

26-09-2007 19:34
Click Here to See the Profile for Bennyk Click here to Send Bennyk a Private Message Find more posts by Bennyk Add Bennyk to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 12:06.    Post New Thread    Post A Reply
Pages (39): « First ... « 10 11 12 13 [14] 15 16 17 18 » ... Last »   Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.239 seconds (40.95% PHP - 59.05% MySQL) con 23 query.