Re: How to redirect the output within a sub-shell (& newgrp)
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix questions > Re: How to redirect the output within a sub-shell (& newgrp)




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Re: How to redirect the output within a sub-shell (& newgrp)  
Michael Paoli


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-08-05 11:29 PM

How about some about some useful hints:
$ cat foo
#!/bin/ksh
id -n -g
[ -f file ] && rm file
$ cat foo
#!/bin/ksh
id -n -g
[ -f file ] && rm file
/usr/bin/newgrp cdrom << \__EOT__
(
echo "I am here"
echo "Bye now"
) > file
__EOT__
ls -g file
[ -f file ] && rm file
$ ./foo
users
-rw-------  1 cdrom 18 Nov  6 16:19 file
$ SHELL=/bin/csh ./foo
users
Too many ('s.
ls: file: No such file or directory
$ 2>>/dev/null fgrep -l "Too many ('s" /bin/*sh* /usr/bin/*sh*
/bin/bsd-csh
/bin/csh
/bin/tcsh
/usr/bin/tcsh
$

Now can you think of the ways the unexpected behavior is likely
creeping in?

venky wrote:
> Thanks Chris for your reply.
> 
>
> Yes we do need it. Its not just accessing the files , also  executing
> some clear case commands(Clear case is a configuration Management tool
> ), doing builds etc.,
> 
>
> Ok let me be clear this time. We have a build script of around 400
> lines of codes of code which contains so many functions, clear case
> commands etc., All these things should be executed in newgrp. I am
> trying to execute a sample script, by  which the same logic  can be
> used for the build script.
>
> 1) I need to execute the script from 'newgrp' which can be done as
> follows.
> /bin/newgrp nemo <<endnewgr
>  set of commands
> endnewgr
>
> 2) I need to redirect the output of each commands, both stdout, stderr
> to a file within newgrp shell. When i try as below,
> /bin/newgrp nemo <<endnewgr
>  (
>     echo "I am here"
>     echo "Bye now"
>  ) > out
> endnewgr
>
> I am getting output as :
> ====
> svenkat@sparta /home/svenkat/work > sh b.sh
> + /bin/newgrp nemo
> (
>   echo "ok"
>   echo "bye now"
> ) > out
> Too many ('s.
> ==========
>
> Otherwords, if
> (
>   echo "ok"
>   echo "bye now"
> ) > out
>
> works why not the previous code is failing to redirect the output
> within newgrp subshell?
> or what needs to be done to achieve the same.






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 03:31 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register