MandrivaThis Forum is for the discussion of Mandriva (Mandrake) Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am rescuing files from a Linux partition onto an USB drive using an Ubuntu live CD. Some of the files have funny characters in them (due to the fact that they reside on a Swedish machine). Ubuntu gets upset and tells me it cannot create those files on the target drive due to those characters. I can only access the partition where the files are as root. My knowledge of Linux is limited (in particular on the command line), so I would need and appreciate some assistance. I have tried using cp, rename and mv, but all of them complain about the characters. What to do?
Here is my feable attempt at a solution. My perl is not very good, so this may not work and I can't test it till I get home. Save the following script as replace_funnies
Code:
#/usr/bin/perl
$infile = $ARGV[1];
$outfile = $ARGV[2];
open (INFILE, "<$infile") or die "Can not open $infile!";
open (OUTFILE, ">$outfile") or die "Can not open $outfile for writing!";
while ($line=<INFILE>) {
$line =~ s/[^\w\s\n\.\?\!]//;
print OUTFILE $line;
}
then do
Code:
chmod +x replace_funnies
to make it executable
You run the script like this
Code:
perl replace_funnies infile outfile
Change infile and outfile to match your situation
Right now it is replacing anything that is not A-Z, a-z, 0-9, ., ?, or !. You can add other characters that you don't want to replace by changeing the s/// line. For example to add ( and ) change it to
Sorry, I was wrong. I typed your program into a file and made it executable. When I ran it, it gave me the complaints:
"
line 3: =: command not found
line 4: =: command not found
"
Could it be the "shift" statement it doesn't like. What does it do?
I checked the contents of my file against your original and couldn't find any diffs.
Probably means you don't have perl installed. Surely ubuntu has perl, its a very common scripting language in linux. Have you looked for it with the synaptic package manager? Do you have your package repositories set up correctly? Post the output of
It looks like there is some kind of Perl installed after all - if I run the script without arguments, it runs the "die" statement so I get the error message correctly. Here is the output from the sources.list:
then there is a commented message regarding support and things.
It says that if I want to add software from the "universe" depository, I should uncomment the two commented lines following. Then comes this:
That's it. It doesn't make much sense to me. I took a look at the URLs listed, but found nothing much.
Now, there might be a problem. I'll try to make the story short.
I was running Mandriva 2006 and tried to upgrade KDE to 3.5, and, apparently, deleted too much of the 3.4 I was running. I couldn't because the root partition was full. Threfore I ended up without the graphical interface. I think the only way I can get it up and running again is to re-install the entire system with a different set of partitions, but before that I'd like to salvage the work I have done. Now, some of the files have Swedish characters in their names, and will therefore not be copied onto the USB drive (as you know). This is the reason I run the Ubuntu system - not to disturbe the /home partition, which I might have if I had re-sized the root partition. There is also an empty partition that I would like to include or simply use as the root. It is big enough. That is a different problem, though.
Something just occurred to me - would there be another live CD distro around which could copy files with funny characters? I have a Knoppix CD and a College CD. Would they be live distros?
Lets try to configure your locales so that you can see those funny characters. First we need to enable root login cause ubuntu doesn't allow it by default.
Code:
sudo passwd root
Then enter your password and a password for the root account. For security reasons, make the root password something hard to guess. Then you can login as root using su. Now as root try to add the locale for the Swedish character set.
Code:
dpkg-reconfigure locales
Pick the locales that you want to use, and then try to look at those files again.
I couldn't tell from your previous post if your x window system is broken or not. You also mentioned something about KDE, but ubuntu uses gnome.
Yeah, I was using KDE in the original Mandriva installation.
I read the Knoppix homepage and found that they appear to specialise in live CDs only, so I took mine and ran it. It works fine, and has got a KDE desktop. I managed to copy the "funny" files too without problem. Then I tried your dpkg command with no success. Both Ubuntu and Knoppix have a "root terminal" which does not require a password (funny, though not really safe).
The USB drive is automatically mounted and display an icon on the desktop. In Knoppix it is mounted as a read-only device. To enable me to copy the files, I had to open the root terminal, unmount the drive and then mount it again to make it writable. Since neither system allow a non-root user to enter the subdirectories of /home, I had to stay as a root. Then "cp -r *" did the trick. The only problem it had is a directory called "Why?", and I can understand that. It i okay, though, because I have it on a CD and I know it has not been touched since.
Thanks a lot for your assistance. Much appreciated.
Ubuntu does not allow direct root login. You have to use sudo, which in my opinion is a silly. That is probably why you could not reconfigure the locales. Not sure what your "root terminal" is, but I doubt if it actually gives you root priveleges. That would be a serious security risk, and would completely defeat the purpose of making you use sudo. Anyway, glad you got it worked out. You should still be able to use the commands above (at least in ubuntu) to get your locales set up once you get to be root.
Well, with the Ubuntu system I was able to copy the files with only the 25 English characters in their names from the "root terminal". I used Knoppix for the rest of the files. I now have all files I wanted on the USB disk. At desktop level I had no access to /home OR the USB-drive, which I had in the "root terminal". Wello, the main thing is that I managed to rescue the files.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.