WinSCP: Using GetFiles() encounter Junction Directory - c++-cli

[Question] Can WinSCP handle Junction directory?
I am using C++/CLI to program a SFTP program using WinSCP .NET assembly (version 5.5.3). My program reads in a schedule file. Originally the source path for get file has to be absolute path. Now that I have to support relative path, I encounter a problem.
Following is to try to get all text files in the home directory. Of course, I want to get all text files within all sub directories inside home directory as well. So I use:
transferOptionObject->FileMask = "*.txt";
transferResult = sftpSession->GetFiles(".", "C:\\temp\\receive", false,
transferOptionObject);
Suppose we use this account terry to log in the remote computer, the remote home directory is /C/Users/terry/Documents. From the session->DebugLog file, I find out WinSCP tries to go over all files and directories within the home directory.
The list is:
* a.txt
* firstDirectory
* My Music
* My Photos
* My Videso
* OtherDirectory
* Other.txt
WinSCP goes over each item in the list. After processing firstDirectory, it tries to process My Music. However it returns an error as not able to process because of Permission Denied.
I then go to the server, and do a dir. I find out those 3 'My' directories are [Junction] as:
29-Apr-14 09:44 <DIR> .
29-Apr-14 09:44 <DIR> ..
16-Jan-14 09:48 <DIR> Documents
16-Jan-14 09:45 <JUNCTION> My Music [C:\Users\terry\Music]
16-Jan-14 09:45 <JUNCTION> My Pictures [C:\Users\terry\Pictures]
16-Jan-14 09:45 <JUNCTION> My Videos [C:\Users\terry\Videos]
I go over these and find out these:
Topic "Sync is broken" ;; Tracker Bug 1132 ;; Topic: "WinSCP doesn't check hardlink target date when synchronizing"
Are they related?

As it's a remote junction/folder, and the SFTP protocol does not know anything about junctions, it's all about your SFTP server. This has nothing to do with client (WinSCP), as it cannot even know it's a junction. Your SFTP server most likely simply presents the junction as a folder. Although it could also present it as a symlink to a folder (but in that case WinSCP would silently skip it).
Side note: The path to the remote target directory should end with a slash.
See https://winscp.net/eng/docs/library_session_getfiles

Related

Copy from a valid csv file but postgres blind to find

I tried to copy csv data to a table with
#+begin_src sql :engine postgresql :dbuser postgres :dbpassword 1618 :database analysis
COPY us_counties_2010
FROM 'data/us_counties_2010.csv'
WITH (FORMAT CSV, HEADER);
#+end_src
It report error
psql:/tmp/babel-x3dXSm/sql-in-zo3MDm:3: ERROR: could not open file "data/us_counties_2010.csv" for reading: No such file or directory
HINT: COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy.
The error "data/us_counties_2010.csv" for reading: No such file or directory does not exits, make no sense.
Because, it does exsit
#+BEGIN_SRC shell
ls -l 'data/us_counties_2010.csv' | sed "s/$USER/me/g"
#+END_SRC
#+RESULTS:
: -rw-rw-r-- 1 me me 1170359 Dec 7 10:22 data/us_counties_2010.csv
What's the problem? Does postgres developers invented yet another arcane path rules to prohibit users?
Where does the file exist? You are using an relative path.
When you use "COPY", what you get is:
The path will be interpreted relative to the working directory of the server process (normally the cluster's data directory), not the client's working directory.
Using \copy rather than COPY will get you not only the client's permissions, but also the clients working directory when searching for the file.
File permissions? I see that "me" has permissions. What user is postgresql?

How to mirror directories using Bitvise sftpc.exe

The Bitvise SSH Client version history states that v8.15 supports directory mirroring:
The graphical SSH Client and sftpc now support recursive directory mirroring. A directory and all of its subdirectories and files can be synchronized either in the upload or download direction.
I can find it in the GUI, but I can't find how to do using sftpc.exe. There is no mention of mirroring in sftpc.exe -help.
How can I do directory mirroring from the command line?
You point out a tangential design issue in sftpc: getting help for SFTP commands requires you to use sftpc interactively and connect to the server. You can then get help from the interactive prompt.
This is inconvenient, so I opened a feature request for us to make the interactive help available from the command line, as well.
The help text you are looking for is as follows - for the put command:
sftp> help put
USAGE: put local-path [remote-path] [-bg | -fg] [-s] [-o] [-r]
[-f] [-noTime] [-m=mode] [-dm=mode] [-mirror [-erase]]
[-b | -lf | -std | -tlf | -t]
DESCRIPTION: Upload file.
PARAMETERS:
-bg Start (queue) upload in background.
-fg Start upload in foreground.
-s Include subdirectories (recursive).
-r Synchronize file content. If synchronization is not available,
resume existing incomplete files using a heuristic resume.
Heuristic resume MAY result in an inconsistent destination file
if the destination file content has been modified in the middle.
-o Synchronize file content. If synchronization is not available,
force existing file to be overwritten. If -r is also specified,
heuristic resume is tried first.
-del Remove local file after successful upload.
-f Assume remote-path is a file (not a directory)
-noTime Do not synchronize file modification times.
-m=mode Set the access mode for remote files to 'mode'.
-dm=mode Set the access mode for new remote directories to 'mode'.
If directory already exists, access mode will not be changed.
-mirror Mirror local-path to remote-path. Local files that do not exist
remotely will be uploaded. Remote files that are different than
their local versions will be overwritten.
-erase With -mirror, erase remote files that are not present locally.
FILE TRANSFER MODE - if present, overrides mode selected with "type":
-b Upload files as binary; no conversions.
-lf Auto-detect text files. In text files, replace CRLF with LF.
Binary files are unaffected.
-std Auto-detect text files. Upload text files using the SFTP v4+ text
file transfer mechanism. Binary files are unaffected. Not
available when SFTP version 3 or lower is in use.
-tlf Upload all files as textual. Replace all CRLF bytes with LF.
-t Upload all files using the SFTP v4+ text file transfer mechanism.
Not available when SFTP version 3 or lower is in use.
And for the get command:
sftp> help get
USAGE: get remote-path [local-path] [-bg | -fg] [-s] [-o] [-r]
[-f] [-noTime] [-lit] [-mirror [-erase]]
[-b | -lf | -std | -tlf | -t]
DESCRIPTION: Download file.
PARAMETERS:
-bg Start (queue) download in background.
-fg Start download in foreground.
-s Include subdirectories (recursive).
-r Synchronize file content. If synchronization is not available,
resume existing incomplete files using a heuristic resume.
Heuristic resume MAY result in an inconsistent destination file
if the destination file content has been modified in the middle.
-o Synchronize file content. If synchronization is not available,
force existing file to be overwritten. If -r is also specified,
heuristic resume is tried first.
-del Remove remote file after successful download.
-f Assume remote-path is a file (not a directory).
-noTime Do not synchronize file modification times.
-lit Treat remote-path literally (not a wildcard pattern).
-mirror Mirror remote-path to local-path. Remote files that do not exist
locally will be downloaded. Local files that are different than
their remote versions will be overwritten.
-erase With -mirror, erase local files that are not present remotely.
FILE TRANSFER MODE - if present, overrides mode selected with "type":
-b Download files as binary; no conversions.
-lf Auto-detect text files. In text files, replace LF with CRLF.
Binary files are unaffected.
-std Behaves same as -lf when downloading. Not available when SFTP
version 3 or lower is in use.
-tlf Download all files as textual. Replace all LF bytes with CRLF.
-t Download all files using the SFTP v4 text file transfer mechanism.
Not available when SFTP version 3 or lower is in use.
I hope this helps!
I don't normally monitor Stack Overflow, so please feel free to call my attention by opening a support case with Bitvise if you need me to look at something else.
I recommend also using the latest Bitvise SSH Client version. Currently, this is 8.35. It's free of charge for use in any environment, and we try to ensure that each version is a strict upgrade that does not introduce new difficulties. We want there to be no reason to stay behind. :-)

'gunzip' is not recognized as an internal or external command, operable program or batch file. System command 'gunzip' failed

I am trying to analyse my raw GNSS data on the GNSS Analyser app from here https://github.com/google/gps-measurement-tools. The installation guide includes the following step:
4.2 gunzip installation
The automatic ftp code inside GnssAnalysis will download ephemeris zip files, and attempt to
unzip them using gunzip.
Download gzip.exe from here http://ftp.gnu.org/gnu/gzip/gzip-1.9.zip
Extract the files from the zip file, rename gzip.exe to gunzip.exe
Move gunzip.exe to somewhere in your Windows path (type path in the Windows
Command Prompt to see what your path is, typically you will find a directory
C:\Windows\system32 and you can put gunzip.exe there.)
However, upon downloading gunzip, I cant find a gzip.exe file, and hence tried renaming the gzip.c and gzip.h file instead. It did not work and I got this error when attempting to process my own raw data.
I have just tried and got success to import DB from a backup file:
gzip -d < C:\Users\my-user\Downloads\my-db-backup.sql.gz | mysql -u root -p MY_DB_NAME

nfsnobody User Privileges

I have setup an NFS file share between two CentOS 6, 64 machines. On the server the folder being shared was originally owned by the root user. On the client it turned up as being owned by nfsnobody. When I tried to write to the folder from the client I got a permissions error. So I changed the folder ownership on the server to nfsnobody and chmod'd it to 777. However, still no joy - I continue to get a permissions error. Clearly, there is more to this. I would be much obliged to any Linux gurus out there (I personally wouldn't merit being called anything more than a newbie) who might be able to help fix this issue.
Edit - I should have mentioned that trying to write to the shared folder from the client actually manages to create a file entry. However, the file size is 0 and the permissions error is reported.
The issue here is to do with the entry in /etc/exports. It should read
folder ip(rw,**all_squash**,sync,no_subtree_check)
I had missed the all_squash bit. That apart, make sure that the folder on the server is owned by nfsnobody. On my setup both my client and server nfsnobodies ended up with a user id if 65534. However, it is well worth checking this (/etc/groups) or else... .
Here are a couple of useful references
How to setup an NFS SErver
NFS on CentOS
For the benefit of anyone looking to setup an NFS server I give below what worked for me on my CentOS 6 64bit machines.
SERVER
yum install nfs-utils nfs-utils-lib - install NFS
rpm -q nfs-utils - check the install
/etc/init.d/rpcbind start
chkconfig --levels 235 nfs on
/etc/init.d/nfs start
chkconfig --level 35 rpcbind on
With this done you should create the folder you want to share
mkdir folder
chown 65534:65534 folder
chmod 755 folder
Now define the folder to be shared/exported. Use your favorite text editor (vi or whatever) to
open/create /etc/exports
folder clientIP (rw,all_squash,sync,no_subtree_check)
Client
Install, check, bind and start as above
mount -t nfs serverIP:folder clientFolderLocation
If all goes well you should now be able to write a little script on your client
<?php
$file = $_SERVER['DOCUMENT_ROOT']."/../nfsfolder/test.txt";
file_put_contents($file,'Hello world of NFS!');
?>
browse to it and find that test.txt now exists on the server with the content "Hello world of NFS". In the example I have placed my mounted drive one level before document_root.

reputation module installation in phpbb3

Hi i am trying to install phpbb-reputation system i followed the xml file for installation but while executing install_reputation.php i am getting this error ERROR: Could not open the file ./styles/afterburnerafterburner_config.html for reading.There are many errors in the same fashin. where i gues it is not going inside afterburner/template folder where .html file exists. where should i check this?
More error samples:
Refreshing the proFormell template
ERROR: Could not open the file ./styles/proFormellcaptcha_recaptcha.html for reading.
Sounds like it's a permissions issue; if hosting on a LAMP server, just run chmod 755 * -R in the website root directory. Alternatively you could also change file permissions using an FTP client