Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ptp-dev] Proper use of IRemoteConnection.setWorkingDirectory()

I got it working! The problem was a bug on my side that was pointing to a path that was not absolute... but of course I was 100% sure it was absolute. 

Our product logs into a remote machine, creates a time-stamped directory in the user's home directory, moves into that directory and does some work. Here's what I used to set the working directory that works for me (pretty much the same as yours above):

String currentWd = connection.getWorkingDirectory();
connection.setWorkingDirectory(currentWd + connection
.getProperty(IRemoteConnection.FILE_SEPARATOR_PROPERTY) + workingDirectoryName);

The variable "workingDirectoryName" is relative to the working directory set at login, normally /home/user.

Thanks again for your help! Looks like everything is working PTP and I'll be able to eliminate about 1000 lines of code and as many headaches. ;)

Jay


On Sat, May 4, 2013 at 8:47 AM, Greg Watson <g.watson@xxxxxxxxxxxx> wrote:
Yes, open the connection first. You might want to check isOpen() to make sure it connected.

Cheers,
Greg

On May 4, 2013, at 8:33 AM, Jay Jay Billings <jayjaybillings@xxxxxxxxx> wrote:

Greg,

Thanks. I will try it again. I assume you set the working directory after the connection was opened?

Jay

-----
Jay Jay Billings
Computational Scientist
Oak Ridge National Laboratory
Twitter Handle: @jayjaybillings

On May 3, 2013 5:05 PM, "Greg Watson" <g.watson@xxxxxxxxxxxx> wrote:
Jay,

I just tried:

connection.setWorkingDirectory("/tmp");
String wd = connection.getWorkingDirectory();
System.out.println("wd = " + wd);

and it prints:

wd = /tmp

So I'm not sure what is going wrong. In fact, looking at the code, the only way this would not work is if the path is not absolute.

Greg

On May 1, 2013, at 4:36 PM, Jay Jay Billings <jayjaybillings@xxxxxxxxx> wrote:

> Everyone,
>
> I am trying to set the working directory of a remote connection by calling IRemoteConnection.setWorkingDirectory(). The JavaDoc says that the path specified needs to be absolute and valid, so I am sending the name of a previously created (~6months back) directory called, for example, /home/jay/scratch. However, calling IRemoteConnection.getWorkingDirectory() always returns the original working directory, in this case /home/jay.
>
> My code is essentially the same as:
>
> connection.setAddress(host);
> connection.setUsername(name);
> connection.setPassword(password);
> connection.open(null);
> connection.setWorkingDirectory("/home/jay/scratch");
>
> Am I missing something?
>
> Thanks for your time!
>
> Jay
>
> --
> Jay Jay Billings
> Oak Ridge National Laboratory
> Twitter Handle: @jayjaybillings
> _______________________________________________
> ptp-dev mailing list
> ptp-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/ptp-dev

_______________________________________________
ptp-dev mailing list
ptp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ptp-dev
_______________________________________________
ptp-dev mailing list
ptp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ptp-dev


_______________________________________________
ptp-dev mailing list
ptp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ptp-dev




--
Jay Jay Billings
Oak Ridge National Laboratory
Twitter Handle: @jayjaybillings

Back to the top