Sftp ing the files and deleting files on remote server.

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Sftp ing the files and deleting files on remote server.

Post by kollurianu »

Hi all ,

After SFTP'ing the source files successfully to the local server , how to delete files from the remote server ? Any inputs greatly appreciated.

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

Post by ArndW »

SFTP allows shelling out on the local host and executing commands. Thus, if your sftp is "push" then it will work, if you "pull" the files then you will need to do something else, perhaps "rsh" or "ssh" to execute the delete command.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Another way of doing this is to run sftp -b (Batch mode)
In the batch file you can write a get/mget followed by a rm
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Post by kollurianu »

ArndW wrote:SFTP allows shelling out on the local host and executing commands. Thus, if your sftp is "push" then it will work, if you "pull" the files then you will need to do something else, perhaps "rsh" or "ssh" to execute the delete command.
Thanks for your response Arnd , I am getting files from remote server to the local datastage server to process them , so how do I do rsh or ssh in the FTP enterprise stage , as I see an open command option but that is used before data transfer .. I need delete files on the remote server after successful tranmission.

Could please elaborate..?Any inputs greatly appreciated.

Thanks in advance.
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Post by kollurianu »

I am doing SFTP in FTP enterprise stage , so is there a way to perform rsh or ssh to delete the file on the remote server.

Thanks in advance.
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Post by kollurianu »

narasimha wrote:Another way of doing this is to run sftp -b (Batch mode)
In the batch file you can write a get/mget followed by a rm
Thanks narsimha for your response , could you please elaborate how this can be done in an FTP enterprise stage as I am using an FTP enterprise stage to pull the files (SFTP) from remote server to local server.

any inputs , greatly appreciated.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

in pull mode you can't execute remote commands so you will have to "ssh" the delete command some other way in your job. Either as an after-job shell call or from the calling job sequence.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The stage has both telnet before and after options, from what I recall. They can be used for tasks such as this, although the fact that this is a secure connection may change that. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I recall reading that sftp doesn't allow remote file actions such as delete, just local ones, so I don't think that this can be done, but it would certainly be worth a try - at worst there will be some error message and best case would be a solved problem!
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Post by kollurianu »

ArndW wrote:in pull mode you can't execute remote commands so you will have to "ssh" the delete command some other way in your job. Either as an after-job shell call or from the calling job sequence.
Thanks for the response Arnd ! In my job sequencer , I've first job as SFTP job , which would pull the files from remote server to the local datastage server. After this how can I remove files from the remote server thru command stage , could you please explain me what command should be executed with syntax.

Any inputs greatly appreciated.Thank you all in advance.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The command would be "rsh" or "ssh" and the exact syntax depends on your flavour of UNIX. Your userid must also be granted rsh or ssh priveleges on the remote machine so you will need to speak with your sysadm to ensure that permission is granted.
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Post by kollurianu »

ArndW wrote:The command would be "rsh" or "ssh" and the exact syntax depends on your flavour of UNIX. Your userid must also be granted rsh or ssh priveleges on the remote machine so you will need to speak with your sysadm to ensure that permission is granted.
Thanks Arnd for a quick response. Datastage (local server) is on Linux and uses /bin/bash shell.

Could you please give me exact syntax to remove file on the remote server thru command stage in a sequencer.

And the id has permissions to delete files on the remote server , do we need any extra permissions to execute rsh/ssh on the remote server.

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

Post by ArndW »

try executing "rsh YourRemoteHostName ls -al" at the command line while logged into the system under the DataStage id. Does it work? If not, what is the error message?
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Post by kollurianu »

ArndW wrote:try executing "rsh YourRemoteHostName ls -al" at the command line while logged into the system under the DataStage id. Does it work? If not, what is the error message?
Thanks Arnd for your response.

I just tried with actual hostname .."rsh abc.def.com ls -al" and below is the error message.

-bash: rsh abc.def.com ls -al: command not found

And my unix id is not enabled to connect to the remote server without username and password only when I run thru datastage SFTP works without the user name and password.

so if you can give me the actual syntax for command activity stage . I shall try and run the sequencer.

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

Post by ArndW »

You will need to talk with your UNIX administrator. It seems that either "rsh" is not installed or not in your path, likewise will most likely be the case for "ssh" as well. Once you sort out getting this command working (with or without adding userid/password) then you can implement it into DataStage.
Post Reply