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 > error message on this script: @: Badly formed number.
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

error message on this script: @: Badly formed number.

Réponse
 
LinkBack Outils de la discussion
Vieux 31/08/2007, 14h32   #1
Janet
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut error message on this script: @: Badly formed number.

What can I do with the following script to get around this error
message. Have not have a problem with this script until now.

Thanks in advance.

Janet
__________________________________________________ ___

#!/bin/csh -
f
# /usr/bin/
clean_mereports
# create monthly directory and move month-end reports to an archive
folder to sa
ve
them

# CREATE MONTHLY
DIRECTORY
set mon=`date +
%m`
set yr=`date +
%Y`
@ mon = $mon -
1
@ yr =
$yr
mkdir /spool/mearchives/retl/$mon
$yr

# MOVE FILE TO /SPOOL/
MEARCHIVES
find /spool/nti/retl -type file -a -name "*" -print|xargs -i -t cp {} /
spool/mea
rchives/retl/$mon$yr >> & /tmp/
clean_mereports.log

find /u1/am/arme -type file -a -name "*RETL" -print|xargs -i -t cp {} /
spool/mea
rchives/retl/$mon$yr >> & /tmp/
clean_mereports.log

find /pbs/spool/am/normal -type file -a -name "FISC*R" -print|xargs -i
-t cp {}
/spool/mearchives/retl/$mon$yr >> & /tmp/clean_mereports.log

  Réponse avec citation
Vieux 31/08/2007, 14h37   #2
Ed Morton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: error message on this script: @: Badly formed number.

Janet wrote:

> What can I do with the following script to get around this error
> message. Have not have a problem with this script until now.
>
> Thanks in advance.
>
> Janet
> __________________________________________________ ___
>
> #!/bin/csh -
> f
> # /usr/bin/
> clean_mereports
> # create monthly directory and move month-end reports to an archive
> folder to sa
> ve
> them
>
> # CREATE MONTHLY
> DIRECTORY
> set mon=`date +
> %m`
> set yr=`date +
> %Y`
> @ mon = $mon -
> 1
> @ yr =
> $yr
> mkdir /spool/mearchives/retl/$mon
> $yr
>
> # MOVE FILE TO /SPOOL/
> MEARCHIVES
> find /spool/nti/retl -type file -a -name "*" -print|xargs -i -t cp {} /
> spool/mea
> rchives/retl/$mon$yr >> & /tmp/
> clean_mereports.log
>
> find /u1/am/arme -type file -a -name "*RETL" -print|xargs -i -t cp {} /
> spool/mea
> rchives/retl/$mon$yr >> & /tmp/
> clean_mereports.log
>
> find /pbs/spool/am/normal -type file -a -name "FISC*R" -print|xargs -i
> -t cp {}
> /spool/mearchives/retl/$mon$yr >> & /tmp/clean_mereports.log
>


a) don't use csh for scripting (see
http://web.archive.org/web/200701061...-faq-2.html#17)
b) your posting is line-wrapping so severely, even in mid-word, that
it's impossible to know what typos the real script might have.

Ed.
  Réponse avec citation
Vieux 31/08/2007, 14h46   #3
Janet
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: error message on this script: @: Badly formed number.

On Aug 31, 8:37 am, Ed Morton <mor...@lsupcaemnt.com> wrote:
> Janet wrote:
> > What can I do with the following script to get around this error
> > message. Have not have a problem with this script until now.

>
> > Thanks in advance.

>
> > Janet
> > __________________________________________________ ___

>
> > #!/bin/csh -
> > f
> > # /usr/bin/
> > clean_mereports
> > # create monthly directory and move month-end reports to an archive
> > folder to sa
> > ve
> > them

>
> > # CREATE MONTHLY
> > DIRECTORY
> > set mon=`date +
> > %m`
> > set yr=`date +
> > %Y`
> > @ mon = $mon -
> > 1
> > @ yr =
> > $yr
> > mkdir /spool/mearchives/retl/$mon
> > $yr

>
> > # MOVE FILE TO /SPOOL/
> > MEARCHIVES
> > find /spool/nti/retl -type file -a -name "*" -print|xargs -i -t cp {} /
> > spool/mea
> > rchives/retl/$mon$yr >> & /tmp/
> > clean_mereports.log

>
> > find /u1/am/arme -type file -a -name "*RETL" -print|xargs -i -t cp {} /
> > spool/mea
> > rchives/retl/$mon$yr >> & /tmp/
> > clean_mereports.log

>
> > find /pbs/spool/am/normal -type file -a -name "FISC*R" -print|xargs -i
> > -t cp {}
> > /spool/mearchives/retl/$mon$yr >> & /tmp/clean_mereports.log

>
> a) don't use csh for scripting (seehttp://web.archive.org/web/20070106111305/home.comcast.net/~j.p.h/cus...)
> b) your posting is line-wrapping so severely, even in mid-word, that
> it's impossible to know what typos the real script might have.
>
> Ed.- Hide quoted text -
>
> - Show quoted text -


Here is the script again. Given that I use csh, what can I do here.
Had to use csh to get my date stuff to work. I have to use what I
have available to me at work. This is a work procedure that runs from
cron once a month. Any advice would be greatly appreciate.

Thanks in advance.

Janet

#!/bin/csh -
f
# /usr/bin/
clean_mereports
# create monthly directory and move month-end reports to an archive
folder to sa
ve
them

# CREATE MONTHLY
DIRECTORY
set mon=`date +
%m`
set yr=`date +
%Y`
@ mon = $mon -
1
@ yr =
$yr
mkdir /spool/mearchives/retl/$mon
$yr

# MOVE FILE TO /SPOOL/
MEARCHIVES
find /spool/nti/retl -type file -a -name "*" -print|xargs -i -t cp {} /
spool/mea
rchives/retl/$mon$yr >> & /tmp/
clean_mereports.log

find /u1/am/arme -type file -a -name "*RETL" -print|xargs -i -t cp {} /
spool/mea
rchives/retl/$mon$yr >> & /tmp/
clean_mereports.log

find /pbs/spool/am/normal -type file -a -name "FISC*R" -print|xargs -i
-t cp {}
/spool/mearchives/retl/$mon$yr >> & /tmp/
clean_mereports.log


  Réponse avec citation
Vieux 31/08/2007, 15h04   #4
janet
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: error message on this script: @: Badly formed number.

On Aug 31, 8:46 am, Janet <jow...@wehco.com> wrote:
> On Aug 31, 8:37 am, Ed Morton <mor...@lsupcaemnt.com> wrote:
>
>
>
>
>
> > Janet wrote:
> > > What can I do with the following script to get around this error
> > > message. Have not have a problem with this script until now.

>
> > > Thanks in advance.

>
> > > Janet
> > > __________________________________________________ ___

>
> > > #!/bin/csh -
> > > f
> > > # /usr/bin/
> > > clean_mereports
> > > # create monthly directory and move month-end reports to an archive
> > > folder to sa
> > > ve
> > > them

>
> > > # CREATE MONTHLY
> > > DIRECTORY
> > > set mon=`date +
> > > %m`
> > > set yr=`date +
> > > %Y`
> > > @ mon = $mon -
> > > 1
> > > @ yr =
> > > $yr
> > > mkdir /spool/mearchives/retl/$mon
> > > $yr

>
> > > # MOVE FILE TO /SPOOL/
> > > MEARCHIVES
> > > find /spool/nti/retl -type file -a -name "*" -print|xargs -i -t cp {} /
> > > spool/mea
> > > rchives/retl/$mon$yr >> & /tmp/
> > > clean_mereports.log

>
> > > find /u1/am/arme -type file -a -name "*RETL" -print|xargs -i -t cp {} /
> > > spool/mea
> > > rchives/retl/$mon$yr >> & /tmp/
> > > clean_mereports.log

>
> > > find /pbs/spool/am/normal -type file -a -name "FISC*R" -print|xargs -i
> > > -t cp {}
> > > /spool/mearchives/retl/$mon$yr >> & /tmp/clean_mereports.log

>
> > a) don't use csh for scripting (seehttp://web.archive.org/web/20070106111305/home.comcast.net/~j.p.h/cus...)
> > b) your posting is line-wrapping so severely, even in mid-word, that
> > it's impossible to know what typos the real script might have.

>
> > Ed.- Hide quoted text -

>
> > - Show quoted text -

>
> Here is the script again. Given that I use csh, what can I do here.
> Had to use csh to get my date stuff to work. I have to use what I
> have available to me at work. This is a work procedure that runs from
> cron once a month. Any advice would be greatly appreciate.
>
> Thanks in advance.
>
> Janet
>
> #!/bin/csh -
> f
> # /usr/bin/
> clean_mereports
> # create monthly directory and move month-end reports to an archive
> folder to sa
> ve
> them
>
> # CREATE MONTHLY
> DIRECTORY
> set mon=`date +
> %m`
> set yr=`date +
> %Y`
> @ mon = $mon -
> 1
> @ yr =
> $yr
> mkdir /spool/mearchives/retl/$mon
> $yr
>
> # MOVE FILE TO /SPOOL/
> MEARCHIVES
> find /spool/nti/retl -type file -a -name "*" -print|xargs -i -t cp {} /
> spool/mea
> rchives/retl/$mon$yr >> & /tmp/
> clean_mereports.log
>
> find /u1/am/arme -type file -a -name "*RETL" -print|xargs -i -t cp {} /
> spool/mea
> rchives/retl/$mon$yr >> & /tmp/
> clean_mereports.log
>
> find /pbs/spool/am/normal -type file -a -name "FISC*R" -print|xargs -i
> -t cp {}
> /spool/mearchives/retl/$mon$yr >> & /tmp/
> clean_mereports.log- Hide quoted text -
>
> - Show quoted text -


Trying to post this again as the copy and paste is causing the
wrapping and preventing a clear picture of the script, this is now
handtyped in here, so hope that you can read it better

#!/bin/csh -f
# /usr/bin/clean_mereports
# create monthly directory and move month-end reports to an archive
folder to save these

# CREATE MONTHLY DIRECTORY
set mon=`date +%m`
set yr=`date +%Y`
@ mon = $mon - 1
@ yr = $yr
mkdir /spool/mearchives/retl/$mon$yr

# MOVE FILE TO /SPOOL/MEARCHIVES
find /spool/nti/retl -type file -a -name "*" -print|xargs -i -t cp {} /
spool/mearchives/retl/$mon$yr >> & /tmp/clean_mereports.log


  Réponse avec citation
Vieux 31/08/2007, 15h38   #5
Icarus Sparry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: error message on this script: @: Badly formed number.

On Fri, 31 Aug 2007 07:04:44 -0700, janet wrote:

> On Aug 31, 8:46 am, Janet <jow...@wehco.com> wrote:
>> On Aug 31, 8:37 am, Ed Morton <mor...@lsupcaemnt.com> wrote:
>>
>>
>>
>>
>>
>> > Janet wrote:
>> > > What can I do with the following script to get around this error
>> > > message. Have not have a problem with this script until now.

>>
>> > > Thanks in advance.

>>
>> > > Janet


[snip]

> Trying to post this again as the copy and paste is causing the wrapping
> and preventing a clear picture of the script, this is now handtyped in
> here, so hope that you can read it better
>
> #!/bin/csh -f
> # /usr/bin/clean_mereports
> # create monthly directory and move month-end reports to an archive
> folder to save these
>
> # CREATE MONTHLY DIRECTORY
> set mon=`date +%m`
> set yr=`date +%Y`
> @ mon = $mon - 1
> @ yr = $yr
> mkdir /spool/mearchives/retl/$mon$yr
>
> # MOVE FILE TO /SPOOL/MEARCHIVES
> find /spool/nti/retl -type file -a -name "*" -print|xargs -i -t cp {} /
> spool/mearchives/retl/$mon$yr >> & /tmp/clean_mereports.log


What was the date when you got this error?
Has there been any change to a program called "date" recently?

I suspect that the problem is because the value of "mon" is "08", and
this looks as if it ought to be an octal number.

There is almost nothing in this script which is made simpler because it
is using csh.

#!/bin/sh
# /usr/bin/clean_mereports
# create monthly directory and move month-end reports to an archive
# folder to save these

mon=`date +%m`
yr=`date +%Y`
mon=`expr $mon - 1`

# uncomment the following line if you want leading zeros on the
# month so things sort better.

# if [ "$mon" -lt 10 ] ; then mon="0$mon" ; fi

# It would probably make more sense to have the archives as $yr$mon,
# again to make things sort better.

dir="/spool/mearchives/ret/$mon$yr"
mkdir "$dir"

find /spool/nti/retl -type file -name "*" -print |
xargs -i -t cp "{}" $dir >> /tmp/clean_mereports.log 2>&1
  Réponse avec citation
Vieux 31/08/2007, 17h13   #6
janet
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: error message on this script: @: Badly formed number.

On Aug 31, 9:38 am, Icarus Sparry <use...@icarus.freeuk.com> wrote:
> On Fri, 31 Aug 2007 07:04:44 -0700, janet wrote:
> > On Aug 31, 8:46 am, Janet <jow...@wehco.com> wrote:
> >> On Aug 31, 8:37 am, Ed Morton <mor...@lsupcaemnt.com> wrote:

>
> >> > Janet wrote:
> >> > > What can I do with the following script to get around this error
> >> > > message. Have not have a problem with this script until now.

>
> >> > > Thanks in advance.

>
> >> > > Janet

>
> [snip]
>
>
>
>
>
> > Trying to post this again as the copy and paste is causing the wrapping
> > and preventing a clear picture of the script, this is now handtyped in
> > here, so hope that you can read it better

>
> > #!/bin/csh -f
> > # /usr/bin/clean_mereports
> > # create monthly directory and move month-end reports to an archive
> > folder to save these

>
> > # CREATE MONTHLY DIRECTORY
> > set mon=`date +%m`
> > set yr=`date +%Y`
> > @ mon = $mon - 1
> > @ yr = $yr
> > mkdir /spool/mearchives/retl/$mon$yr

>
> > # MOVE FILE TO /SPOOL/MEARCHIVES
> > find /spool/nti/retl -type file -a -name "*" -print|xargs -i -t cp {} /
> > spool/mearchives/retl/$mon$yr >> & /tmp/clean_mereports.log

>
> What was the date when you got this error?
> Has there been any change to a program called "date" recently?
>
> I suspect that the problem is because the value of "mon" is "08", and
> this looks as if it ought to be an octal number.
>
> There is almost nothing in this script which is made simpler because it
> is using csh.
>
> #!/bin/sh
> # /usr/bin/clean_mereports
> # create monthly directory and move month-end reports to an archive
> # folder to save these
>
> mon=`date +%m`
> yr=`date +%Y`
> mon=`expr $mon - 1`
>
> # uncomment the following line if you want leading zeros on the
> # month so things sort better.
>
> # if [ "$mon" -lt 10 ] ; then mon="0$mon" ; fi
>
> # It would probably make more sense to have the archives as $yr$mon,
> # again to make things sort better.
>
> dir="/spool/mearchives/ret/$mon$yr"
> mkdir "$dir"
>
> find /spool/nti/retl -type file -name "*" -print |
> xargs -i -t cp "{}" $dir >> /tmp/clean_mereports.log 2>&1- Hide quoted text -
>
> - Show quoted text -


It ran fine last month but wouldn't run this month. I think that your
suspicion is correct.

  Réponse avec citation
Vieux 31/08/2007, 22h49   #7
janet
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: error message on this script: @: Badly formed number.

On Aug 31, 11:13 am, janet <jow...@wehco.com> wrote:
> On Aug 31, 9:38 am, Icarus Sparry <use...@icarus.freeuk.com> wrote:
>
>
>
>
>
> > On Fri, 31 Aug 2007 07:04:44 -0700, janet wrote:
> > > On Aug 31, 8:46 am, Janet <jow...@wehco.com> wrote:
> > >> On Aug 31, 8:37 am, Ed Morton <mor...@lsupcaemnt.com> wrote:

>
> > >> > Janet wrote:
> > >> > > What can I do with the following script to get around this error
> > >> > > message. Have not have a problem with this script until now.

>
> > >> > > Thanks in advance.

>
> > >> > > Janet

>
> > [snip]

>
> > > Trying to post this again as the copy and paste is causing the wrapping
> > > and preventing a clear picture of the script, this is now handtyped in
> > > here, so hope that you can read it better

>
> > > #!/bin/csh -f
> > > # /usr/bin/clean_mereports
> > > # create monthly directory and move month-end reports to an archive
> > > folder to save these

>
> > > # CREATE MONTHLY DIRECTORY
> > > set mon=`date +%m`
> > > set yr=`date +%Y`
> > > @ mon = $mon - 1
> > > @ yr = $yr
> > > mkdir /spool/mearchives/retl/$mon$yr

>
> > > # MOVE FILE TO /SPOOL/MEARCHIVES
> > > find /spool/nti/retl -type file -a -name "*" -print|xargs -i -t cp {} /
> > > spool/mearchives/retl/$mon$yr >> & /tmp/clean_mereports.log

>
> > What was the date when you got this error?
> > Has there been any change to a program called "date" recently?

>
> > I suspect that the problem is because the value of "mon" is "08", and
> > this looks as if it ought to be an octal number.

>
> > There is almost nothing in this script which is made simpler because it
> > is using csh.

>
> > #!/bin/sh
> > # /usr/bin/clean_mereports
> > # create monthly directory and move month-end reports to an archive
> > # folder to save these

>
> > mon=`date +%m`
> > yr=`date +%Y`
> > mon=`expr $mon - 1`

>
> > # uncomment the following line if you want leading zeros on the
> > # month so things sort better.

>
> > # if [ "$mon" -lt 10 ] ; then mon="0$mon" ; fi

>
> > # It would probably make more sense to have the archives as $yr$mon,
> > # again to make things sort better.

>
> > dir="/spool/mearchives/ret/$mon$yr"
> > mkdir "$dir"

>
> > find /spool/nti/retl -type file -name "*" -print |
> > xargs -i -t cp "{}" $dir >> /tmp/clean_mereports.log 2>&1- Hide quoted text -

>
> > - Show quoted text -

>
> It ran fine last month but wouldn't run this month. I think that your
> suspicion is correct.- Hide quoted text -
>
> - Show quoted text -


Since there seems to be no real solution to this and csh is not a good
shell to program in, what shell do you recommend and what would my
code be in the recommended shell?

Thanks in advance!

Janet

  Réponse avec citation
Vieux 01/09/2007, 00h41   #8
Neil Cherry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: error message on this script: @: Badly formed number.

On Fri, 31 Aug 2007 07:04:44 -0700, janet wrote:
> On Aug 31, 8:46 am, Janet <jow...@wehco.com> wrote:
>> On Aug 31, 8:37 am, Ed Morton <mor...@lsupcaemnt.com> wrote:
>> > Janet wrote:
>> > > What can I do with the following script to get around this error
>> > > message. Have not have a problem with this script until now.


> #!/bin/csh -f
> # /usr/bin/clean_mereports
> # create monthly directory and move month-end reports to an archive
> folder to save these
>
> # CREATE MONTHLY DIRECTORY
> set mon=`date +%m`
> set yr=`date +%Y`
> @ mon = $mon - 1
> @ yr = $yr
> mkdir /spool/mearchives/retl/$mon$yr
>
> # MOVE FILE TO /SPOOL/MEARCHIVES
> find /spool/nti/retl -type file -a -name "*" -print|xargs -i -t cp {} \
> /spool/mearchives/retl/$mon$yr >> & /tmp/clean_mereports.log


The problem is the if the Month is August (08) or september (09) they
don't exist in Octal. What you need to do is convert 08 into 8, then
do the math, then convert it back to 08 for the rest of the commands.
The shell won't matter as bash, sh and csh all treat the 08 as an
octal. Your work around may be something like this (done in shell,
not csh):

# Interesting problem, what is 08? According to shell it doesn't exists it
# thinks the number is octal!

case "x${mon}" in
"x08")
mon=8
;;
"x09")
mon=9
;;
*)
mon=${M}
;;
esac

Then if you have printf (it's on Linux as a command, not just a C
function) on your system you can do something like this:

str=`printf "/spool/mearchives/retl/%02d%s" $mon $yr`
mkdir $str

Otherwise you'll need something else such as awk. If you need Perl
you might as well write the whole thing in Perl.

--
Linux Home Automation Neil Cherry ncherry@linuxha.com
http://www.linuxha.com/ Main site
http://linuxha.blogspot.com/ My HA Blog
Author of: Linux Smart Homes For Dummies
  Réponse avec citation
Vieux 01/09/2007, 07h41   #9
Icarus Sparry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: error message on this script: @: Badly formed number.

On Fri, 31 Aug 2007 14:49:15 -0700, janet wrote:

> On Aug 31, 11:13 am, janet <jow...@wehco.com> wrote:
>> On Aug 31, 9:38 am, Icarus Sparry <use...@icarus.freeuk.com> wrote:
>>
>>
>>
>>
>>
>> > On Fri, 31 Aug 2007 07:04:44 -0700, janet wrote:
>> > > On Aug 31, 8:46 am, Janet <jow...@wehco.com> wrote:
>> > >> On Aug 31, 8:37 am, Ed Morton <mor...@lsupcaemnt.com> wrote:

>>
>> > >> > Janet wrote:
>> > >> > > What can I do with the following script to get around this
>> > >> > > error message. Have not have a problem with this script until
>> > >> > > now.

>>
>> > >> > > Thanks in advance.

>>
>> > >> > > Janet

>>
>> > [snip]

>>
>> > > Trying to post this again as the copy and paste is causing the
>> > > wrapping and preventing a clear picture of the script, this is now
>> > > handtyped in here, so hope that you can read it better

>>
>> > > #!/bin/csh -f
>> > > # /usr/bin/clean_mereports
>> > > # create monthly directory and move month-end reports to an archive
>> > > folder to save these

>>
>> > > # CREATE MONTHLY DIRECTORY
>> > > set mon=`date +%m`
>> > > set yr=`date +%Y`
>> > > @ mon = $mon - 1
>> > > @ yr = $yr
>> > > mkdir /spool/mearchives/retl/$mon$yr

>>
>> > > # MOVE FILE TO /SPOOL/MEARCHIVES
>> > > find /spool/nti/retl -type file -a -name "*" -print|xargs -i -t cp
>> > > {} / spool/mearchives/retl/$mon$yr >> & /tmp/clean_mereports.log

>>
>> > What was the date when you got this error? Has there been any change
>> > to a program called "date" recently?

>>
>> > I suspect that the problem is because the value of "mon" is "08", and
>> > this looks as if it ought to be an octal number.

>>
>> > There is almost nothing in this script which is made simpler because
>> > it is using csh.

>>
>> > #!/bin/sh
>> > # /usr/bin/clean_mereports
>> > # create monthly directory and move month-end reports to an archive #
>> > folder to save these

>>
>> > mon=`date +%m`
>> > yr=`date +%Y`
>> > mon=`expr $mon - 1`

>>
>> > # uncomment the following line if you want leading zeros on the #
>> > month so things sort better.

>>
>> > # if [ "$mon" -lt 10 ] ; then mon="0$mon" ; fi

>>
>> > # It would probably make more sense to have the archives as $yr$mon,
>> > # again to make things sort better.

>>
>> > dir="/spool/mearchives/ret/$mon$yr"
>> > mkdir "$dir"

>>
>> > find /spool/nti/retl -type file -name "*" -print |
>> > xargs -i -t cp "{}" $dir >> /tmp/clean_mereports.log 2>&1-
>> > Hide quoted text -

>>
>> > - Show quoted text -

>>
>> It ran fine last month but wouldn't run this month. I think that your
>> suspicion is correct.- Hide quoted text -
>>
>> - Show quoted text -

>
> Since there seems to be no real solution to this and csh is not a good
> shell to program in, what shell do you recommend and what would my code
> be in the recommended shell?
>
> Thanks in advance!
>
> Janet


A POSIX shell is suggested, 'sh', 'ksh', bash', 'zsh' are all reasonable
choices.

The code in any of them would look like the code higher up the page
starting "#!/bin/sh".
  Réponse avec citation
Vieux 02/09/2007, 00h46   #10
Chris F.A. Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: error message on this script: @: Badly formed number.

On 2007-08-31, Neil Cherry wrote:
....
> The problem is the if the Month is August (08) or september (09) they
> don't exist in Octal. What you need to do is convert 08 into 8, then
> do the math, then convert it back to 08 for the rest of the commands.
> The shell won't matter as bash, sh and csh all treat the 08 as an
> octal. Your work around may be something like this (done in shell,
> not csh):
>
> # Interesting problem, what is 08? According to shell it doesn't exists it
> # thinks the number is octal!
>
> case "x${mon}" in
> "x08")
> mon=8
> ;;
> "x09")
> mon=9
> ;;
> *)
> mon=${M}
> ;;
> esac


The use $mon in arithmetic, simply use ${mon#0} instead of $mon.

> Then if you have printf (it's on Linux as a command, not just a C
> function) on your system you can do something like this:
>
> str=`printf "/spool/mearchives/retl/%02d%s" $mon $yr`


If you need to ensure that $mon is two digits:

case ${#mon} in 1) mon=0$mon ;; esac

Then, to build the directory name there is no need for command
substitution (which is slow in all shells but ksh93) and printf:

str=/spool/mearchives/retl/$mon$yr

> mkdir $str


--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
  Réponse avec citation
Vieux 02/09/2007, 04h48   #11
Neil Cherry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: error message on this script: @: Badly formed number.

On Sat, 1 Sep 2007 19:46:24 -0400, Chris F.A. Johnson wrote:
> On 2007-08-31, Neil Cherry wrote:
> ...
>> The problem is the if the Month is August (08) or september (09) they
>> don't exist in Octal. What you need to do is convert 08 into 8, then
>> do the math, then convert it back to 08 for the rest of the commands.
>> The shell won't matter as bash, sh and csh all treat the 08 as an
>> octal. Your work around may be something like this (done in shell,
>> not csh):
>>
>> # Interesting problem, what is 08? According to shell it doesn't exists it
>> # thinks the number is octal!
>>
>> case "x${mon}" in
>> "x08")
>> mon=8
>> ;;
>> "x09")
>> mon=9
>> ;;
>> *)
>> mon=${M}
>> ;;
>> esac

>
> The use $mon in arithmetic, simply use ${mon#0} instead of $mon.
>
>> Then if you have printf (it's on Linux as a command, not just a C
>> function) on your system you can do something like this:
>>
>> str=`printf "/spool/mearchives/retl/%02d%s" $mon $yr`

>
> If you need to ensure that $mon is two digits:
>
> case ${#mon} in 1) mon=0$mon ;; esac
>
> Then, to build the directory name there is no need for command
> substitution (which is slow in all shells but ksh93) and printf:
>
> str=/spool/mearchives/retl/$mon$yr


Thanks, while I'm not the OP but I appreciate the knowledge. :-)

--
Linux Home Automation Neil Cherry ncherry@linuxha.com
http://www.linuxha.com/ Main site
http://linuxha.blogspot.com/ My HA Blog
Author of: Linux Smart Homes For Dummies
  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 17h28.


É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,30587 seconds with 19 queries