Is it possible to update svn using a windows environmental variable folder? - windows

I have tortoiseSVN installed alongside subversion for windows (not using TortoiseSVN command client tools because of restrictive purposes).
I have a batch file that runs an svn update on certain folders which are used as environmental variables in Windows. Is it possible to svn update a folder using just the folder name?
e.g. from this:
cd C:\foo\johnsmith\testing\
svn update
to something like this?
cd testing\
svn update
I should add that environmental variables are new to me...
With regards to Alrocs comment, the path C:\foo\johnsmith\testing\ is in the system environmental variable "Path".

You can't cd to directory, which is part of your $PATH$. But you can use environment variable, which explicitly contain needed path only (after all - variable is just string)
c:\TEMP>echo "%USERPROFILE%"
"C:\Documents and Settings\Badger"
c:\TEMP>cd "%USERPROFILE%"
C:\Documents and Settings\Badger>

Never assume anything about environment variables that you haven't set via your batch file. Just because it's there today/on your computer doesn't necessarily mean it'll be there tomorrow or on another computer.
But you aren't using an environment variable in your script in the first place.
If you need to update a specific path, be explicit and update that path by specifying the whole path. Don't assume that your testing directory will be an immediate child of the directory you're running the batch file in unless you can control everything else - the whole subdirectory structure, where the batch file executes from, and how it executes.

Related

Windows CMD Shorten file path

I got Gnu Utilities that adds the command sed to windows, but to use it I have to type:
C:\ProgramFiles\GnuWin32\bin\sed.exe <args>
How do I shorten this to just sed <args>?
To run an executable without a full path, it needs to be either in the current directory, or in the PATH environment variable. In the CMD prompt, there are several ways to do this.
The first way is to put C:\ProgramFiles\GnuWin32\bin in your PATH variable, which makes every program in that directory available without a full path.
set "PATH=%path%;C:\ProgramFiles\GnuWin32\bin"
This updates PATH in the current command prompt. If you need to set it for other CMD windows, see How to persistently set a variable in Windows 7 from a batch file?
The second method is to have sed.exe in the current directory. The most obvious way to do that is to change directories.
cd C:\ProgramFiles\GnuWin32\bin
sed
Or you can copy it to your current directory.
copy C:\ProgramFiles\GnuWin32\bin\sed.exe .\
sed
(This works with sed.exe because it's a self-contained utility. Don't try this with a Windows application like excel.exe)
Finally, you can create a "redirect" somewhere in the current directory or the path.
>.\sed.bat echo C:\ProgramFiles\GnuWin32\bin\sed.exe %*
This creates a batch file in the current directory called sed.bat that calls the full sed.exe. You can drop this file into any directory in your PATH.
mklink .\sed.exe C:\ProgramFiles\GnuWin32\bin\sed.exe
This creates a symlink to the sed.exe in the current directory, much like a symlink in Unix or a shortcut in Windows.

Windows environment variable issue

I have two environment variables defined as:
test1=C:\something\dir1
test2=C:\something\dir2
And I'm trying to run the following command:
copy dir1\filename.txt dir2\filename.txt
I know that if I write the copy command with the environment variables it will work, like below:
copy %test1%\filename.txt %test2%\filename.txt
But isn't there a better way to do this? If Windows doesn't find the "dir1" directory in its current directory, won't it try to find it with the system variables it has?
EDIT: Im trying to use the copy command without typing the enviroment variable's name in the command.
Something like "copy dir1\filename.txt dir2\filename.txt", where, if Windows cant find the dir1 directory in its current directory, it would automatically search this directory with the enviroment variables. Is this possible?
This will copy the fully qualified path and filename, and cater for spaces etc.
copy "%test1%\filename.txt" "%test2%\"
If it doesn't work for you then edit your question and give more details about the task.

cwrsync in windows not being recognised

I am trying to move from a mac environment to a windows one and require rsync.
Found cwrsync # http://www.rsync.net/resources/howto/windows_rsync.html
I have installed the cwrsync program fine, I can call the rsync at cmd but on when in the directory which contains the sync.exe
When in command prompt, if i call rsync when not in the relavent directory it moans and sayS:
"rsync" is not recognised as an internal or external command, operable
program or batch file.
Is there a way to add the rsync.exe to a global list so as rsync is recognised outside of its immediate parent directory?
Thanks,
John
Add the path in the Windows system variables:
- Control Panel -> System -> tab Advanced, button Environment Variables.
- Edit the "Path" system variable and add the full path to the installed rsync:
C:\Program Files\cwRsync\bin or C:\cygwin\bin. or
C:\Program Files (x86)\cwRsync\bin or C:\cygwin\bin.
This way the commands rsync and ssh should run from any directory. Make sure you put in the correct install path to the application else it won't work. See screenshot below:
Environment Variable Setup: Make sure the path you added is under System Variables:
Command: As seen, I am running this directly from root of C: drive
cwRsync distribution contains a batch file example called cwrsync.cmd with correct path settings. You can simply add your rsync command into that file.

Configuring Cyqwin to make using ./ unnecessary

In order for me to run a .exe or a .sh in Cyqwin, I have to put a ./ at the beginning of my line. Is there a way for me to change this so that isn't necessary? This is causing problems when I try and run a test script and it can't find files that are right in the directory I'm working in.
The reason you must use a './' is to specifically tell the shell what file you are trying to execute. Without the leading './', your $PATH environment variable is searched. You can try adding the directories with scripts and executables you commonly use to your $PATH if you'd like. Alternatively, you can add the current directory (.) to your $PATH, but this is a Very Bad Idea as it can lead to unintentional executions.
From the cygwin environment variables doc:
The PATH environment variable is used by Cygwin applications as a list
of directories to search for executable files to run. This environment
variable is converted from Windows format (e.g.
C:\Windows\system32;C:\Windows) to UNIX format (e.g.,
/cygdrive/c/Windows/system32:/cygdrive/c/Windows) when a Cygwin
process first starts. Set it so that it contains at least the
x:\cygwin\bin directory where "x:\cygwin is the "root" of your cygwin
installation if you wish to use cygwin tools outside of bash.

Where do I put mxmlc so that I could just type 'mxmlc' in the terminal to compile a swf file?

I'm on a Mac and I'm trying to make a Vim plugin for compiling/running actionscript files.
First, I need to run mxmlc on the command line, but to do that I have to keep on typing the path to it. Where do I place it so that I don't have to retype the path?
You need to modify your "$PATH" environment variable, so that the tool is in that directory. However, if you want to make this very easy... you can download my macosx-environment-setup.tar.bz2 program. If you execute the "install.sh" script using "sudo ./install.sh", it will setup your environment in such a way that if you use "/Library/Flex4SDK" as the location for the Flex4SDK, it will automatically find it, define FLEX_HOME to point to that location, and it will also ensure that the binaries from the Flex4SDK are in your PATH.
Side Note: This is up on the web, because I use it in my Development Environment Setup How-To Guides. If you aren't too keen about running "sudo ./install.sh", you need to choose a location (I am going to assume "/Library/Flex4SDK", so that the tools are located in "/Library/Flex4SDK/bin"), and then you would simply need to edit your "~/.profile" file (using "nano ~/.profile"), adding the following to the very end:
export FLEX_HOME=/Library/Flex4SDK
export PATH="$PATH":"$FLEX_HOME/bin"
Note that these changes occur in your shell... they will not affect programs that are launched by double-clicking them in Finder. In order to affect those programs, you will need to place the environment variables in a file named ~/.MacOSX/environment.plist. See Automatically build ~/.MacOSX/environment.plist for a script that will automatically generate such a file using the current environment variables defined in your shell.
There are a few ways to answer this:
In one of your directories searched
by PATH (see the list with echo
$PATH)
Add a new directory to PATH
(e.g. in your ~/.bashrc
export PATH=$PATH:/path/to/bindir)
Add an
alias to your program (e.g. in your
~/.bashrc alias
mxmic=/path/to/mxmic)
(I'm assuming you're using bash shell, which is usually the case you can check with echo $SHELL)

Resources