Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to convert this script to AIX shell?

31 views
Skip to first unread message

Limin

unread,
Sep 9, 2009, 3:54:05 PM9/9/09
to
I use the following command to place Oracle export in Solaris with
KSH.

echo|exp file=>(gzip|split -b 2047m - exp.dmp.) userid=system/passwd
full=y

It performs a full database export and compress the export file on the
fly. When the first compressed file is larger than 2G, it will create
a second compressed export file, and so on. So for the large database,
the export files look like:

exp.dmp.aa
exp.dmp.ab
exp....

It was so convenient to use. However, I could not seem to be able to
run it with KSH in AIX. In AIX, it doesn't recognize file=>

Has anyone come across the similar issue in AIX? What is the
workaround?

TIA

Limin.

Janis Papanagnou

unread,
Sep 9, 2009, 4:06:41 PM9/9/09
to
Limin schrieb:

> I use the following command to place Oracle export in Solaris with
> KSH.
>
> echo|exp file=>(gzip|split -b 2047m - exp.dmp.) userid=system/passwd
> full=y
>
> It performs a full database export and compress the export file on the
> fly. When the first compressed file is larger than 2G, it will create
> a second compressed export file, and so on. So for the large database,
> the export files look like:
>
> exp.dmp.aa
> exp.dmp.ab
> exp....
>
> It was so convenient to use. However, I could not seem to be able to
> run it with KSH in AIX. In AIX, it doesn't recognize file=>

I suspect the idiom => is misleading here; rather it seems to be part
of a process substitution >( ... ) Process substitution is available
not before ksh93, AFAIKT, but the ksh's on the AIX versions I used ten
years ago were all ksh'88.

Janis

Stephane CHAZELAS

unread,
Sep 9, 2009, 4:49:08 PM9/9/09
to
2009-09-09, 23:06(+03), Janis Papanagnou:

> Limin schrieb:
>> I use the following command to place Oracle export in Solaris with
>> KSH.
>>
>> echo|exp file=>(gzip|split -b 2047m - exp.dmp.) userid=system/passwd
>> full=y
>>
>> It performs a full database export and compress the export file on the
>> fly. When the first compressed file is larger than 2G, it will create
>> a second compressed export file, and so on. So for the large database,
>> the export files look like:
>>
>> exp.dmp.aa
>> exp.dmp.ab
>> exp....
>>
>> It was so convenient to use. However, I could not seem to be able to
>> run it with KSH in AIX. In AIX, it doesn't recognize file=>
>
> I suspect the idiom => is misleading here; rather it seems to be part
> of a process substitution >( ... ) Process substitution is available
> not before ksh93, AFAIKT, but the ksh's on the AIX versions I used ten
> years ago were all ksh'88.

process substitution is available in some ksh88 as well as long
as the system supports /dev/fd/<x>.

When the system doesn't have /dev/fd/<x>, you can use named
pipes instead.

mkfifo p
< p gzip | split -b 2047m - exp.dmp. &
echo | exp file=p user...

If the system has /dev/fd/<x> but ksh88 just happens to miss the
process substitution feature, then you can do:

{
echo | exp file=/dev/fd/3 useri... 3>&1 >&4 |
gzip | split -n 2047m - exp.dmp.
} 4>&1

Note that not all implementations of process substitution allow
it to be part of a word.

--
Stï¿œphane

Limin

unread,
Sep 9, 2009, 5:27:47 PM9/9/09
to Limin
Stéphane and Janis,

Thanks a lot for the explanations. I don't see /dev/fd/<x> in my aix
box, so I tested Stéphane's first suggestion, it works perfectly.

Limin.

On Sep 9, 4:49 pm, Stephane CHAZELAS <stephane_chaze...@yahoo.fr>
wrote:

> Stéphane

hpt

unread,
Sep 10, 2009, 4:15:06 AM9/10/09
to
On Sep 10, 4:49 am, Stephane CHAZELAS <stephane_chaze...@yahoo.fr>
wrote:

Why needs '>&4' and '4>&1' here? What do they do?

> Note that not all implementations of process substitution allow
> it to be part of a word.
>
> --

> Stéphane

Stephane CHAZELAS

unread,
Sep 10, 2009, 5:13:04 AM9/10/09
to
2009-09-10, 01:15(-07), hpt:
[...]
>> {
>> ᅵ echo | exp file=/dev/fd/3 useri... 3>&1 >&4 |
>> ᅵ ᅵ gzip | split -n 2047m - exp.dmp.

>>
>> } 4>&1
>>
>
> Why needs '>&4' and '4>&1' here? What do they do?

4>&1 dupplicates the outer stdout to fd 4, >&4, aka 1>&4
restores "exp's" stdout to that same resource. So, the overall
effect is to preserve exp's stdout. Otherwise, anything written
by "exp" on its stdout would go to the pipe to gzip as well.

If you want to make things tidy, you could do:
{
echo 4>&- | exp file=/dev/fd/3 useri... 3>&1 >&4 4>&- |
gzip 4>&- | split -n 2047m - exp.dmp. 4>&-

} 4>&1

To close that fd 4 fall all the commands as none of them use it
(nor should they use it).

--
Stï¿œphane

hpt

unread,
Sep 10, 2009, 5:56:22 AM9/10/09
to
On Sep 10, 5:13 pm, Stephane CHAZELAS <stephane_chaze...@yahoo.fr>
wrote:

> 2009-09-10, 01:15(-07), hpt:
> [...]
>
> >> {
> >>   echo | exp file=/dev/fd/3 useri... 3>&1 >&4 |
> >>     gzip | split -n 2047m - exp.dmp.
>
> >> } 4>&1
>
> > Why needs '>&4' and '4>&1' here? What do they do?
>
> 4>&1 dupplicates the outer stdout to fd 4, >&4, aka 1>&4
> restores "exp's" stdout to that same resource. So, the overall
> effect is to preserve exp's stdout. Otherwise, anything written
> by "exp" on its stdout would go to the pipe to gzip as well.
>
> If you want to make things tidy, you could do:
> {
>   echo 4>&- | exp file=/dev/fd/3 useri... 3>&1 >&4 4>&- |
>     gzip 4>&- | split -n 2047m - exp.dmp. 4>&-
>
> } 4>&1
>
> To close that fd 4 fall all the commands as none of them use it
> (nor should they use it).
>
> --
> Stéphane

Thanks very much :)

0 new messages