unzip in unix

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
naren6876
Participant
Posts: 233
Joined: Mon Feb 07, 2005 7:19 pm

unzip in unix

Post by naren6876 »

Hi,
I have written a Before/After Subroutine as below. And it is errored out.

SUBROUTINE unzip(InputArg,ErrorCode)
Command = 'unzip /TESTZIP/xyz.zip'

Call DSExecute("UNIX",Command,Output,SystemReturnCode)

If SystemReturnCode <> 0
Then
Message = "Error when executing command: " : Command
Call DSLogWarn(Message, "unzip()")
End
Else
Message = "Executed command: " : Command
Call DSLogWarn(Message, "unzip()")

End


ErrorCode = 0 ;* set this to non-zero to stop the stage/job

anyone can throw some light on this please.

Thnaks in advance.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

It would be very helpful if you could actually tell us what the error is. You should also include the contents of the variable Output in your error message.
naren6876
Participant
Posts: 233
Joined: Mon Feb 07, 2005 7:19 pm

Post by naren6876 »

ArndW wrote:It would be very helpful if you could actually tell us what the error is. You should also include the contents of the variable Output in your error message. ...

It doesn't say anything. But it always logs it as warning with the message

Error when executing command: unzip /TESTZIP/xyz.zip.


why it is not unziiping the zip file.?.

Thanks
meena
Participant
Posts: 430
Joined: Tue Sep 13, 2005 12:17 pm

Re: unzip in unix

Post by meena »

Hi,
Can you check with "

Code: Select all

SUBROUTINE unzip(InputArg,ErrorCode)"
.In your code I do not see InputArg. I am not sure the error is because of this or for something.Post the error.

Code: Select all

SUBROUTINE unzip(InputArg,ErrorCode)
Command = 'unzip /TESTZIP/xyz.zip'

Call DSExecute("UNIX",Command,Output,SystemReturnCode)

If SystemReturnCode <> 0 
Then 
   Message = "Error when executing command: " : Command
   Call DSLogWarn(Message, "unzip()")  
End 
Else 
   Message = "Executed command: " : Command
   Call DSLogWarn(Message, "unzip()")  

End 


ErrorCode = 0      ;* set this to non-zero to stop the stage/job
naren6876
Participant
Posts: 233
Joined: Mon Feb 07, 2005 7:19 pm

Re: unzip in unix

Post by naren6876 »

meena wrote:Hi,
Can you check with "

Code: Select all

SUBROUTINE unzip(InputArg,ErrorCode)"
.In your code I do not see InputArg. I am not sure the error is because of this or for something.Post the error.

Code: Select all

SUBROUTINE unzip(InputArg,ErrorCode)
Command = 'unzip /TESTZIP/xyz.zip'

Call DSExecute("UNIX",Command,Output,SystemReturnCode)

If SystemReturnCode <> 0 
Then 
   Message = "Error when executing command: " : Command
   Call DSLogWarn(Message, "unzip()")  
End 
Else 
   Message = "Executed command: " : Command
   Call DSLogWarn(Message, "unzip()")  

End 


ErrorCode = 0      ;* set this to non-zero to stop the stage/job

do we need to have InputArg in the code.?

Thanks,
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

As Arnd suggested, add the Output variable to your error message like this

Code: Select all

Message = "Error when executing command: " : Command : Output
and then see what exactly is causing the error. It will be easier to debug that way.
Kris

Where's the "Any" key?-Homer Simpson
naren6876
Participant
Posts: 233
Joined: Mon Feb 07, 2005 7:19 pm

Post by naren6876 »

kris007 wrote:As Arnd suggested, add the Output variable to your error message like this

Code: Select all

Message = "Error when executing command: " : Command : Output
and then see what exactly is causing the error. It will be easier to debug that way.
Hi.
when i use the option 'o' it ran ok.
unzip -o /TESTZIP/xyz.zip

But i cant see the file in the folder.
the Output variable has the value

Archive: /TESTZIP/xyz.zip
inflating: xyz.txt

any clues about this.

Thanks in advance.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

DataStage jobs shell out with a current attach point / working directory of the project that the job runs in. Check there for the output file.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

DataStage jobs shell out with a current attach point / working directory of the project that the job runs in. Check there for the output file.
naren6876
Participant
Posts: 233
Joined: Mon Feb 07, 2005 7:19 pm

Post by naren6876 »

ArndW wrote:DataStage jobs shell out with a current attach point / working directory of the project that the job runs in. Check there for the output file. ...
Hi,

How can i change the directory in the routine. so that it can place the file where the zip file is.

Thanks in advance.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is there another option for unzip to specify the target location?

If not, change the command to

Code: Select all

cd pathname && unzip -o /TESTZIP/xyz.zip 
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
naren6876
Participant
Posts: 233
Joined: Mon Feb 07, 2005 7:19 pm

Post by naren6876 »

ray.wurlod wrote:Is there another option for unzip to specify the target location?

If not, change the command to

Code: Select all

cd pathname && unzip -o /TESTZIP/xyz.zip 
...
yes. I have other location to store the unzipped files.How can i do that?.

How can i give morethan one parameter to Before/After subroutine?.
Because my InputArg contains the Complete path including zip file name.

Thnaks in advance.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You can have as much as you like in InputArg. Put some kind of delimiter between each piece, and use the Field() function in your subroutine to parse them out.
For example, the Input Values field might contain #SourcePath#|#TargetPath#

Code: Select all

SourcePath = Field(InputArg, "|", 1, 1)
TargetPath = Field(InputArg, "|", 2, 1)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply