[Risolto]Codifica reindirizzando file .txt(encoding=ascii)

Se avete problemi con l'installazione e la configurazione di Slackware postate qui. Non usate questo forum per argomenti generali... per quelli usate Gnu/Linux in genere.

Moderatore: Staff

Regole del forum
1) Citare sempre la versione di Slackware usata, la versione del Kernel e magari anche la versione della libreria coinvolta. Questi dati aiutano le persone che possono rispondere.
2) Per evitare confusione prego inserire in questo forum solo topic che riguardano appunto Slackware, se l'argomento è generale usate il forum Gnu/Linux in genere.
3) Leggere attentamente le risposte ricevute.
4) Scrivere i messaggi con il colore di default, evitare altri colori.
5) Scrivere in Italiano o in Inglese, se possibile grammaticalmente corretto, evitate stili di scrittura poco chiari, quindi nessuna abbreviazione tipo telegramma o scrittura stile SMS o CHAT.
6) Appena registrati è consigliato presentarsi nel forum dedicato.

La non osservanza delle regole porta a provvedimenti di vari tipo da parte dello staff, in particolare la non osservanza della regola 5 porta alla cancellazione del post e alla segnalazione dell'utente. In caso di recidività l'utente rischia il ban temporaneo.
Rispondi
Avatar utente
unonessuno
Linux 1.x
Linux 1.x
Messaggi: 137
Iscritto il: dom 27 giu 2010, 3:59
Slackware: 14.0
Kernel: 3.2.29-smp
Desktop: XFCE4.10

[Risolto]Codifica reindirizzando file .txt(encoding=ascii)

Messaggio da unonessuno »

Ciao.

Come da titolo, se ad esempio volglio reindirizzare da terminale un manuali nella mia home in formato .txt, il sistema non è in grado di visualizzarlo in modo correto.

Prendendo come esempio il :"man di alien" questo è il risultato:

Codice: Seleziona tutto

man alien > man_alien.txt
Ovviamente mi crea in:"~/home " il file:"man_alien.txt" ma con questo risultato:

Codice: Seleziona tutto

ALIEN(1)              User Contributed Perl Documentation             ALIEN(1)



NNAAMMEE
       alien - Convert or install an alien binary package

SSYYNNOOPPSSIISS
        alien [--to-deb] [--to-rpm] [--to-tgz] [--to-slp] [options] file [...]

DDEESSCCRRIIPPTTIIOONN
       aalliieenn is a program that converts between Red Hat rpm, Debian deb,
       Stampede slp, Slackware tgz, and Solaris pkg file formats. If you want
       to use a package from another linux distribution than the one you have
       installed on your system, you can use aalliieenn to convert it to your
       preferred package format and install it. It also supports LSB packages.

WWAARRNNIINNGG
       aalliieenn should not be used to replace important system packages, like
       init, libc, or other things that are essential for the functioning of
       your system. Many of these packages are set up differently by the
       different distributions, and packages from the different distributions
       cannot be used interchangeably. In general, if you can't remove a
       package without breaking your system, don't try to replace it with an
       alien version.

PPAACCKKAAGGEE FFOORRMMAATT NNOOTTEESS
       rpm For converting to and from rpm format the Red Hat Package Manager
           must be installed...............
Per completezza vi posto i files:"/etc/profile.d/lang.sh" e "/etc/profile.d/lang.csh":

Codice: Seleziona tutto

#!/bin/sh
# Set the system locale.  (no, we don't have a menu for this ;-)
# For a list of locales which are supported by this machine, type:
#   locale -a

# en_US is the Slackware default locale:
#export LANG=en_US
export LANG=it_IT.utf8
# 'C' is the old Slackware (and UNIX) default, which is 127-bit
# ASCII with a charmap setting of ANSI_X3.4-1968.  These days,
# it's better to use en_US or another modern $LANG setting to
# support extended character sets.
#export LANG=C

# There is also support for UTF-8 locales, but be aware that
# some programs are not yet able to handle UTF-8 and will fail to
# run properly.  In those cases, you can set LANG=C before
# starting them.  Still, I'd avoid UTF unless you actually need it.
#export LANG=en_US.UTF-8

# Another option for en_US:
#export LANG=en_US.ISO8859-1

# One side effect of the newer locales is that the sort order
# is no longer according to ASCII values, so the sort order will
# change in many places.  Since this isn't usually expected and
# can break scripts, we'll stick with traditional ASCII sorting.
# If you'd prefer the sort algorithm that goes with your $LANG
# setting, comment this out.
export LC_COLLATE=C

# End of /etc/profile.d/lang.sh

Codice: Seleziona tutto

#!/bin/csh
# Set the system locale.  (no, we don't have a menu for this ;-)
# For a list of locales which are supported by this machine, type:
#   locale -a

# en_US is the Slackware default locale:
#setenv LANG en_US
setenv LANG it_IT.utf8
# 'C' is the old Slackware (and UNIX) default, which is 127-bit
# ASCII with a charmap setting of ANSI_X3.4-1968.  These days,
# it's better to use en_US or another modern $LANG setting to
# support extended character sets.
#setenv LANG C

# There is also support for UTF-8 locales, but be aware that
# some programs are not yet able to handle UTF-8 and will fail to
# run properly.  In those cases, you can set LANG=C before
# starting them.  Still, I'd avoid UTF unless you actually need it.
#setenv LANG en_US.UTF-8

# Another option for en_US:
#setenv LANG en_US.ISO8859-1

# One side effect of the newer locales is that the sort order
# is no longer according to ASCII values, so the sort order will
# change in many places.  Since this isn't usually expected and
# can break scripts, we'll stick with traditional ASCII sorting.
# If you'd prefer the sort algorithm that goes with your $LANG
# setting, comment this out.
setenv LC_COLLATE C

# End of /etc/profile.d/lang.csh

Su debian mi dava lo stesso problema, ma ho risolto inserendo in:"~/home/.bashrc " il seguente script:

Codice: Seleziona tutto

function mantotext()
{
man --encoding=ascii $1 >  file.txt
editor file.txt
rm file.txt
}

Prendendo come esempio il man di alien, mi basta aprire un terminale e dare:

Codice: Seleziona tutto

mantotext alien
E me lo apre direttamente nell'editor predefinito di sistema, nel caso di Debian-Gnome "Gedit" con XFCE4 Mousepad, con i caratteri visualizzati in modo correto.
Ho provato a fare la stessa, ho inserito lo script all'interno di ".bashrc " presente in ~/home di Slackware 13.1 ma non funziona per nulla, si limita ad aprire mousepad "IN BIANCO" non riporta nemmeno una riga del manuale.

-Qualcuno mi sa spiegare come dovrei fare per risolvere??

PS:E' mia consuetudine reidirizzare e salvare in una directori i manuali che più mi interessano, per averli sempre a portata di mano, lo trovo molto comodo, inoltre la mancata codifica potrebbe generare in futuro errori e problemi anche seri oltre ad inutili perdidte di tempo .

Grazie.
Ultima modifica di unonessuno il ven 4 feb 2011, 23:22, modificato 2 volte in totale.

Avatar utente
414N
Iper Master
Iper Master
Messaggi: 2924
Iscritto il: mer 13 feb 2008, 16:19
Slackware: 15.0
Kernel: 5.15.19
Desktop: KDE5
Località: Bulagna
Contatta:

Re: Codifica caratterri reindirizzando file .txt(encoding=as

Messaggio da 414N »

Io sono solito trasformare le man page in pdf tramite questo comando:

Codice: Seleziona tutto

man -t X | ps2pdf - X.pdf
dove X è il manuale che voglio trasformare in PDF.
Se vuoi trasformarlo in un semplice txt, forse ti tornerà utile l'opzione -t di man.
man man ha scritto: -t Usa /usr/bin/groff -Tps -mandoc per formattare la pagina di manuale, passando l'out‐
put a stdout. Il formato di output predefinito di /usr/bin/groff -Tps -mandoc è
Postscript, fare riferimento alla pagina di manuale di /usr/bin/groff -Tps -mandoc
per vedere i modi per scegliere un formato alternativo.

Avatar utente
unonessuno
Linux 1.x
Linux 1.x
Messaggi: 137
Iscritto il: dom 27 giu 2010, 3:59
Slackware: 14.0
Kernel: 3.2.29-smp
Desktop: XFCE4.10

Re: Codifica caratterri reindirizzando file .txt(encoding=as

Messaggio da unonessuno »

Ciao.
Ti ringrazio ugualmente, quel comando e la relativa tools li conosco, sono utili e li adopero ma, è una cosa diversa, in soataza non risolve il probelma in questione.
Per completezza di informazione, se apro un manuale da terminale e poi con il "copia ed incolla" lo copio in un editor come mousepad e simili, lo visualizza e lo salva senza errori (Tale procedimento, come facilmente intuibile è alquanto scomodo); la cosa strana è che non fa lo stesso quando provo a reinderizzarlo in un'altra directory nel formato:".txt" .
Spero non manchi qualche pacchetto "essenziale" o importante di sistema.

Ciao e Grazie.

Avatar utente
414N
Iper Master
Iper Master
Messaggi: 2924
Iscritto il: mer 13 feb 2008, 16:19
Slackware: 15.0
Kernel: 5.15.19
Desktop: KDE5
Località: Bulagna
Contatta:

Re: Codifica caratterri reindirizzando file .txt(encoding=as

Messaggio da 414N »

Da una ricerca rapida su zio Google, ho trovato il seguente suggerimento:

Codice: Seleziona tutto

man command_name | col  -b > output_file_name
L'ho provato e mi funziona. Prova un po' sul tuo sistema...

Avatar utente
unonessuno
Linux 1.x
Linux 1.x
Messaggi: 137
Iscritto il: dom 27 giu 2010, 3:59
Slackware: 14.0
Kernel: 3.2.29-smp
Desktop: XFCE4.10

Re: Codifica caratterri reindirizzando file .txt(encoding=as

Messaggio da unonessuno »

Funziona, bravo.
In pratica ho risolto, posso reindirizzarli e salvarli anche così.
Esempio man su:

Codice: Seleziona tutto

man su | col  -b > output_man.txt
Mi ha generato in :"~home" questo file:

Codice: Seleziona tutto

NOME
       su - change user ID or become superuser

SINOSSI
       su [opzioni] [username]

DESCRIZIONE
       The su command is used to become another user during a login session.
       Invoked without a username, su defaults to becoming the superuser. The
       optional argument - may be used to provide an environment similar to
       what the user would expect had the user logged in directly.

       Dopo il nome utente, è possibile specificare argomenti aggiuntivi da
       passare alla shell di login dell´utente. In particolare, molti
       interpreti di comando adottano la convenzione per cui l´opzione -c
       seguita da un argomento fa sì che quest´ultimo sia considerato un
       comando.Il comando viene eseguito dalla shell specificata in
       /etc/passwd per l´utente di destinazione.

       You can use the -- argument to separate su options from the arguments
       supplied to the shell...........................
Come puoi vedere il risultato è perfetto.

Grazie.
Ciao.

Rispondi