Re: system: cd

From: David Ian Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Tue, 18 Apr 2006 11:01:13 -0600

Each call to 'system' starts a sub-shell that is exited before the call
returns.
A solution is to put multiple commands in a single system call using
'&&' or ';' to separate
the commands.
E.g.:

ncl 0> system("cd")
ncl 1> system("pwd")
/datazone/dsszone/tigge/daily_input/ecmf/missing
ncl 2> system("cd && pwd")
/home/dbrown
ncl 3> system("cd ; pwd")
/home/dbrown
ncl 4>
  -dave

On Apr 18, 2006, at 10:44 AM, Michael Notaro wrote:

> I must be missing something obvious. Why doesn't
> system( "cd coupl" ) work? I want to change into the
> coupl directory but it never works.
>
> Mike
>
>
>
> begin
>
> numb=(/794880, 819360, 826560, 833760, 840960, 848160, 855360, 862560,
> 869760, 766080, \
> 802080, 820800, 828000, 835200, 842400, 849600, 856800, 864000,
> 871200, 773280, \
> 809280, 822240, 829440, 836640, 843840, 851040, 858240, 865440,
> 872640, 780480, \
> 816480, 823680, 830880, 838080, 845280, 852480, 859680, 866880,
> 874080, 760320, \
> 787680, 817920, 825120, 832320, 839520, 846720, 853920, 861120,
> 868320, 875520 /)
> do iy=0,1
> filename="rs."+numb(iy)+".tar"
> system( "tar -xvf "+filename )
> system( "cd coupl" )
> system( "mv restart.colpj.0"+numb(iy)+" restart.colpj.old" )
> system( "cd .." )
> system( "f77 edit_restart_borens.f" )
> system( "a.out" )
> system( "cd coupl" )
> system( "mv restart.colpj.new restart.colpj.0"+numb(iy) )
> system( "rm restart.colpj.old" )
> system( "cd .." )
> end do
>
> end
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Apr 18 2006 - 11:01:13 MDT

This archive was generated by hypermail 2.2.0 : Thu Apr 20 2006 - 09:30:53 MDT