get the current HEAD version of a CVS file on the server - linux

Using the rlog command I can analyze the commit log to a file on the CVS server itself (that is, directly accessing the file ending in ",v"). That's fine.
Is there a similar command line utility that prints the current HEAD version of that file to stdout?
I need this for a custom CVS status utility (something like ViewVC, but made specifically for a certain repository) that will be written in PHP.

To print the content of the file that would be checked out, just use co -p filename. That will print a small header including the revision number to stderr, and the content of the file to stdout.

You probably want cvs log filename. Not sure buy you might need to do cvs update filename first.

Related

Configuration file pulled from S3 segfaults OpenSwan

I'm trying to configure OpenSwan, an open source IPsec solution written in C.
I have a script to download a configuration file ipsec.conf on an Amazon Linux EC2 that was created on my Macbook and uploaded to S3.
When I start the ipsec service, it segfaults.
Curiously, if I open the configuration file with VIM, make no changes, and simply write/quit, it works. This lends me to believe somehow the file has some weird characters/formatting.
I know of dos2unix, which I ran on the configuration file but that did not prevent the segfault.
I'm wondering what exactly VIM is doing when I write/quit. I could script that operation on my configuration file after pulling it. Or anything else that would help me understand what's going on.
First, try to open the file with vim, then exit vim (:q) without having saved the file before. If vim says File modified since last complete write; write or use ! to override., this means that this is not something that vim does when write/quit that changes your file, but that this is something that vim does when it opens the file. And this is the most common case.
Vim parses the input file depending on the locale, and if some characters can not be understood according to the locale, vim may forget them. So, when saving the file, those characters will be removed.
Now, use vim to save your file as ipsec-ok.conf.
And run the following command:
bash -c 'diff <(od -xa ipsec.conf) <(od -xa ipsec-ok.conf)'
This will display the differences between the original file and the one that works with OpenSwan. In ascii and hexadecimal formats. This way, you will find the unsupported characters that make OpenSwan dump a core.

How to overwrite ".listing" file when using "wget" command

I have a generic script that uses wget to download the file (passed as parameter to the script) from FTP server. The script always downloads the files into the same local folder. The problem I am running into is that .listing file created by wget gets deleted by default so if the script is called in parallel for different files, whichever process gets to delete the .listing file succeeds and the rest fail.
So I tried to use --no-remove-listing along with wget command, but then I get the error:
File ".listing" already there; not retrieving.
I looked at another post but as mentioned in the comments by original poster, the question hasn't been answered even though it is marked so.
One option I was thinking about is to change the script to create subdirectory with filename and download the file there. But since it is a large script, I was trying to see if there is an easier option to just change wget command.

Batch/Macro code to get latest file from FTP site

We have a shared FTP site with a daily file upload which I need to download and run checks over. I'm simply trying to automate the process. The FTP file is something like name_20150901.xml.
So far I have a batch file to get the file but I can't figure out how to get the latest. Here is my code:
#ftp -i -s:"%~f0"&GOTO:EOF
open ftp.site.com
<user>
<pass>
lcd my local direc
binary
get todaysfile_20150901.xml
What changes do I need to read the files and get the newest one? My end goal is to have a macro that calls this and then reads the file that's grabbed from the FTP and runs my checks.
There's no easy way to select the most recent file with the ftp.exe.
If you know that the file has today's timestamp, you can generate the script dynamically with the today's timestamp. You can use the DATE environment variable, though it has its caveats. A more reliable (and complex) way is to use the wmic os get LocalDateTime.
See How to get current datetime on Windows command line, in a suitable format for using in a filename?
If you can determine the latest file alphabetically, you can:
run the ftp.exe with the ls command redirected to a file
sort the files by alphabet in a descending order
read the first line
generate a download script for the second ftp.exe run
WinSCP can download the files created within the last 24-hours (1 day):
winscp.com /command ^
"open ftp://user:pass#ftp.site.com/" ^
"lcd c:\my\local\direc" ^
"get *>=1D" ^
"exit"
If you really need to download the latest file (by timestamp), you probably need some more advanced scripting.
For example there's a guide available for downloading the most recent file with WinSCP.
(I'm the author of WinSCP)

SVN Pre-commit Symbolic Link Path in Perl

In my workplace, there's one Perl script that runs on a Unix machine every time someone tries to check-in a file to the SVN repo for any of the 10-20 projects.
The way it works is that each project has its own "Hooks" folder with a file called "pre-commit" which SVN automatically executes when someone check-in something. Except the "pre-commit" file is actually a symbolic link to the one central Perl script common to all projects just so that if a change needs to be made to the Perl script it doesn't need to be done for every project.
So my problem is this: I need to put a text file in each of these projects' "hooks" directory, each one containing some settings specific to that project. So there will be 10-20 settings files (one per project) each in their respective "hooks" directory.
The problem is that I need to open these text files in the Perl script and read from them but I'm having issues letting Perl know where to find it. I tried using the $0 parameter which is supposed to tell me where the script is being executed from but because it's a symbolic link it just says "Not a directory" and the script terminates. I need to get the path of the "hooks" directory so that I can find the text file.
The SVN pre-commit script is supposed to be invoked with the path to the repository as its first argument. Inside a Perl script, that argument should be available as $ARGV[0]. You should be able to build the path to the corresponding hooks directory or to a file inside that directory by simply appending to the repository path, like this:
$repopath = $ARGV[0];
$hookspath = $repopath . "/hooks";
$myfilepath = $hookspath . "/myfile";
although for maximum portability it would be cleaner to use the pathname-manipulation functions in the File::Spec module to do this.
If this approach doesn't work then you'll have to explain more about how your Perl script gets invoked. For instance, if your pre-commit script is really a shell script wrapper that eventually invokes perl then perhaps it's not passing the pre-commit arguments along properly.
Showing us your current code that's failing would be a good thing too.

Access TortoiseSVN update text

When you use Tortoise SVN to update from the repository to your local machine, you get the popup that shows what files were added/updated/etc. I'm looking to get hold of that text programmatically.
Do you know if it's dumped to a temporary file or a log file? Or is there another way to get hold of that text? I can't see anything in the settings that provides for it.
One idea might be to use the svn.exe console program, like this
svn.exe log -r head -v <svn-dir>
-r means the revision (head being the newest)
-v being verbose (which includes the file names)
<svn-dir> is a dir that contains a svn checkout ( this can be omitted if you run the command inside such a dir).
There are also an -xml switch that might be useful if you want to massage the data in some way
This requires that you have a svn.exe in you path. It seems to be possible to find the svn.exe exec. here

Resources