PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Cygwin script issue
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Cygwin script issue

Réponse
 
LinkBack Outils de la discussion
Vieux 06/05/2008, 22h48   #1
Sashi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Cygwin script issue

All, I've got a directory with a bunch of files. I want to move
certain files into a different directory. The list of files is in a
text file.
When I try to do it in a for loop

for file in $(cat routers); do cp $file ../configs/.; done

I'm getting a message saying:
cp: cannot stat `russwdc-cpv21-7206\r': No such file or directory

I'm not sure how to get rid of the '\r' here.

Can someone out?

Thanks,
Sashi
  Réponse avec citation
Vieux 07/05/2008, 00h24   #2
Janis Papanagnou
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cygwin script issue

Sashi wrote:
> All, I've got a directory with a bunch of files. I want to move
> certain files into a different directory.


This Cygwin environment (or rather the WinDOS environment) can be a pain.

> The list of files is in a
> text file.
> When I try to do it in a for loop
>
> for file in $(cat routers); do cp $file ../configs/.; done
>
> I'm getting a message saying:
> cp: cannot stat `russwdc-cpv21-7206\r': No such file or directory
>
> I'm not sure how to get rid of the '\r' here.
>
> Can someone out?


I'd try the following...

dos2unix routers

while read file
do cp "$file" ../configs/
done < routers


Janis

>
> Thanks,
> Sashi

  Réponse avec citation
Vieux 07/05/2008, 05h09   #3
Gary Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cygwin script issue

Sashi <smalladi@gmail.com> wrote:
> All, I've got a directory with a bunch of files. I want to move
> certain files into a different directory. The list of files is in a
> text file.
> When I try to do it in a for loop
>
> for file in $(cat routers); do cp $file ../configs/.; done
>
> I'm getting a message saying:
> cp: cannot stat `russwdc-cpv21-7206\r': No such file or directory
>
> I'm not sure how to get rid of the '\r' here.
>
> Can someone out?


You created the 'routers' file using a program that ends each line with
the DOS-style CR-LF. Bash expects lines to end with only LF so it
treats the CR ('\r') as part of the line. In your case, that CR becomes
part of the file name.

To fix that in Cygwin, you can use the 'd2u' program to convert DOS line
endings to Unix line endings, e.g.,

d2u routers

--
Gary Johnson
  Réponse avec citation
Vieux 07/05/2008, 14h08   #4
Sashi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cygwin script issue

On May 6, 7:24 pm, Janis Papanagnou <Janis_Papanag...@hotmail.com>
wrote:
> Sashi wrote:
> > All, I've got a directory with a bunch of files. I want to move
> > certain files into a different directory.

>
> This Cygwin environment (or rather the WinDOS environment) can be a pain.
>
> > The list of files is in a
> > text file.
> > When I try to do it in a for loop

>
> > for file in $(cat routers); do cp $file ../configs/.; done

>
> > I'm getting a message saying:
> > cp: cannot stat `russwdc-cpv21-7206\r': No such file or directory

>
> > I'm not sure how to get rid of the '\r' here.

>
> > Can someone out?

>
> I'd try the following...
>
> dos2unix routers
>
> while read file
> do cp "$file" ../configs/
> done < routers
>
> Janis
>
>
>
> > Thanks,
> > Sashi


I should've known..
Thanks!
Sashi
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h41.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15709 seconds with 12 queries