WinSCP and Unix directory variables

Advertisement

johnb
Joined:
Posts:
1

WinSCP and Unix directory variables

I am using WinSCP to sftp to a Solaris box from a Windows PC and would like to cd to an variable. For example cd $MYDIR. From there I would get my file. Is there any way to get this accomplished?

Reply with quote

Advertisement

jpantera
Joined:
Posts:
23
Location:
Los Angeles, CA

Re: WinSCP and Unix directory variables

johnb wrote:

I am using WinSCP to sftp to a Solaris box from a Windows PC and would like to cd to an variable. For example cd $MYDIR. From there I would get my file. Is there any way to get this accomplished?

You'll need to define the variable on the Windows side, and pass it to the WinSCP command that way (once connected to the Unix host, it's a simple dummy ftp program... Many years ago palyed around with stuff like this, but once you're inside the winscp "open" it's not going ot allow any logic on the Unix host).

Reply with quote

richp
Joined:
Posts:
1
Location:
Willowbridge Associates Inc

WinSCP and Unix directory variables

If I logon to a VMS host that has a Logical defined for a folder, I can CD to that logical and it works.
So why doesn’t the same thing work in UNIX trying to CD to an environment variable?

Here is a VMS terminal session to show the logical of OMR$DAT:
Username: wilprodaxp
Password:
Last interactive login on Friday, 16-FEB-2018 09:08:51.59
WILPRODAXP> show logical omr$dat
"OMR$DAT" = "PROD$1_AXP:[TRADEMGRWILL.DAT]" (LNM$PROCESS_TABLE)
"OMR$DAT" = "DSA100:[TRADEMGRWILL.DAT]" (LNM$GROUP_000205)
WILPRODAXP> show default
PROD$2:[WILPRODAXP]
WILPRODAXP> set default omr$dat
WILPRODAXP> show default
PROD$1_AXP:[TRADEMGRWILL.DAT]

WILPRODAXP>

Here is a command line SFTP session that can CD to OMR$DAT:
N:\WinSCP-5.12.2>WinSCP.com
winscp> open chucky
Searching for host...
Connecting to host...
Authenticating...
Username: wilprodaxp
Password:
Authenticated.
Starting the session...
Session started.
Active session: [1] chucky
winscp> pwd
/DSA100/wilprodaxp
winscp> cd omr$dat
/DSA100/trademgrwill/dat

winscp>

Here is a UNIX terminal session to show the environment variable of $OMR_DAT:
{wbtrad01} su - wilprod
Password:
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
{wilprod} pwd
/wbqa/wilprod
{wilprod} echo $OMR_DAT
/wbqa/dat
{wilprod} cd $OMR_DAT
{wilprod} pwd
/wbqa/dat

{wilprod}

Here is a command line SFTP session that cannot CD to $OMR_DAT:
winscp> open 178.20.10.33
Searching for host...
Connecting to host...
Authenticating...
Username: wilprod
Using keyboard-interactive authentication.
Password:
Authenticated.
Starting the session...
Session started.
Active session: [2] 178.20.10.33
winscp> pwd
/wbqa/traders/wilprod
winscp> cd $OMR_DAT
Error changing directory to '$OMR_DAT'.
Cannot get real path for '/wbqa/traders/wilprod/$OMR_DAT'.
No such file or directory.
Error code: 2
Error message from server: No such file
/wbqa/traders/wilprod

winscp>

Reply with quote E-mail

jpantera
Joined:
Posts:
23
Location:
Los Angeles, CA

Re: WinSCP and Unix directory variables

richp wrote:

If I logon to a VMS host that has a Logical defined for a folder, I can CD to that logical and it works.
So why doesn’t the same thing work in UNIX trying to CD to an environment variable?

Here is a VMS terminal session to show the logical of OMR$DAT:
Username: wilprodaxp
Password:
Last interactive login on Friday, 16-FEB-2018 09:08:51.59
WILPRODAXP> show logical omr$dat
"OMR$DAT" = "PROD$1_AXP:[TRADEMGRWILL.DAT]" (LNM$PROCESS_TABLE)
"OMR$DAT" = "DSA100:[TRADEMGRWILL.DAT]" (LNM$GROUP_000205)
WILPRODAXP> show default
PROD$2:[WILPRODAXP]
WILPRODAXP> set default omr$dat
WILPRODAXP> show default
PROD$1_AXP:[TRADEMGRWILL.DAT]

WILPRODAXP>

Here is a command line SFTP session that can CD to OMR$DAT:
N:\WinSCP-5.12.2>WinSCP.com
winscp> open chucky
Searching for host...
Connecting to host...
Authenticating...
Username: wilprodaxp
Password:
Authenticated.
Starting the session...
Session started.
Active session: [1] chucky
winscp> pwd
/DSA100/wilprodaxp
winscp> cd omr$dat
/DSA100/trademgrwill/dat

winscp>

Here is a UNIX terminal session to show the environment variable of $OMR_DAT:
{wbtrad01} su - wilprod
Password:
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
{wilprod} pwd
/wbqa/wilprod
{wilprod} echo $OMR_DAT
/wbqa/dat
{wilprod} cd $OMR_DAT
{wilprod} pwd
/wbqa/dat

{wilprod}

Here is a command line SFTP session that cannot CD to $OMR_DAT:
winscp> open 178.20.10.33
Searching for host...
Connecting to host...
Authenticating...
Username: wilprod
Using keyboard-interactive authentication.
Password:
Authenticated.
Starting the session...
Session started.
Active session: [2] 178.20.10.33
winscp> pwd
/wbqa/traders/wilprod
winscp> cd $OMR_DAT
Error changing directory to '$OMR_DAT'.
Cannot get real path for '/wbqa/traders/wilprod/$OMR_DAT'.
No such file or directory.
Error code: 2
Error message from server: No such file
/wbqa/traders/wilprod

winscp>

VMS... Are you talking Vax VMS?

That's ancient, if so. I learned Vax VMS ages ago, and preferred it to Unix (but Unix won out, now Linux / Wintel, etc...). With it's remote access tools, maybe it gave more access (do they still update a VMS OS?).

Here, you're talking ftp remote access, and what you can do. ftp shells are kept intentionally "dumb", for obvious reasons in today's day & age (you have people who routinely go to a server remotely and try to do bad things).

My recommendation (and as a disclaimer am still pretty new to scripting with winscp, but understand once I'm connected, you probably will only get the basic ftp commands), is to build whatever logic you want outside the ftp / sftp other protocol connection, and use that way.

Anything with winscp specifically, I'll pass to an admin here.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,517
Location:
Prague, Czechia

Re: WinSCP and Unix directory variables

What you do works with VMS as VMS FTP server itself recognizes the "Logical defined for a folder".
While what you do does not work with *nix, as no common *nix FTP server does recognizes environment variables.
Moreover I believe that VMS logical is rather an equivalent of *nix symlink, not an environment variable. Isn't it? And common *nix FTP servers do recognize symlinks.

Overall, your question is not about WinSCP at all.

Reply with quote

Advertisement

You can post new topics in this forum