I am trying to recreate a zip command from windows in Unix and facing issues as expected.
Windows command is
zip "zipfilename.zip" -j -u -m -g -T -9 "sourcefiledirectory\*20181010.*
On UNIX the pattern *20181010.* is not getting identified and i am getting the message
"zip warning: name not matched".
Please help in getting over this.
You have specified the wildcard path in Windows format (i.e. using "\" for the path separator, rather than "/")
"sourcefiledirectory\*20181010.*"
try this instead
"sourcefiledirectory/*20181010.*"
I was able to execute the command on the command line in unix but was getting issues while trying to replicate the same through an ETL tool 'BODS'. The issue was fixed when i put the command into a .sh executable and called that executable from BODS by passing the zipfile name and source file pattern as parameters.
Related
I am trying to execute git commands with a public SSH key using the system() function in R (on Windows 7 64 bit). When I try to execute a git command I get the following error:
ssh_askpass: exec(rpostback-askpass): No such file or directory
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I can run the exact same command on the command prompt and it works. I can also run the exact same command on the git bash shell and it works. I am not sure why cmd can't find the key when run from R using the system() command. Is there a way to specify the key location for the command prompt used by the system() command?
Update:
An example call that won't work:
system("git push --set-upstream git#gitlab.mygit.com:MyGroup/testGitlab.git master")
also
system("git clone git#gitlab.mygit.com:MyGroup/gitLabTest.git")
Both of these calls get the same error above.
Update 2: It appears that the ssh keys are not visible from R using list.files()
> list.files("C:/Users/Me/Documents/.ssh/", all.files = TRUE)
[1] "." ".."
I have verified that there are multiple ssh keys in this directory which are visible from the git bash shell using ls -a.
As it turns out, on my Windows system (7, 64 bit), when creating SSH keys with the git bash shell they were saved to "C:\Users\MyAcount\.ssh". However, the cmd.exe called by system() in R was looking in "C:\Users\MyAccount\Documents\.ssh".
For some reason, when using the cmd prompt called directly from the OS it looks in the same .ssh directory as the bash shell. Go Figure. Windows, I don't think I will ever understand you. Hope this helps someone out there.
I want to use 7zip command line from sas. I confirmed these commands work from the command line, but I can't get it to work in a sas program. I think this has to do with setting the unix path in SAS. Does anyone know how I could accomplish this?
data _null_;
length command1 command2 $1000;
command1 = 'set PATH=%PATH%;C:\Program Files\7-zip\';
command2 = '7z x "\\mypath\zip.zip" -pmypassword -y -o"\\mypath"';
call system(command1);
call system(command2);
run;
I use it all the time. Here is an example that zips a file from my work folder and adds a password to the zip. Windows example obviously. If running in a corporate environment you may want to ensure you have access to execute shell commands from within SAS (such as %sysexec).
%sysexec "C:\Program Files\7-Zip\7z.exe" a -y -pMyPassword %sysfunc(pathname(work))\DestinationFilename.zip %sysfunc(pathname(work))\SourceFilename.csv;
How am i able to execute UNIX commands on my PC Command prompt? Note i do not have cygwin installed, although i was going to before i discovered this.
This is a development machine so i have a lot installed on it like ruby, python, git, github, node and so on.
What does this mean? can i use this without cygwin?
Here is a list of programs installed on my PC program list
How am I able to execute UNIX commands on my PC Command prompt?
You can use the where command in a cmd shell to find out the exact location of your Unix commands, for example:
where ls
This assumes, of course, that ls is located somewhere in your current PATH.
The location returned will show you in which directory your Unix commands are installed and may be enough for you to determine how they were installed.
The where command is roughly equivalent to the Unix which command.
By default, the search is done in the current directory and in the
PATH.
Syntax
WHERE [/r Dir] [/q] [/f] [/t] Pattern ...
WHERE [/q] [/f] [/t] [$ENV:Pattern
Source where
Further Reading
An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
where - Locate and display files in a directory tree.
Running Unix commands in windows can be done by having a tool like Cygwin which has those commands.
You can also get many of those commands compiled for windows and then run them using the command with the full path or only the command if the executable is in a path known by adding the paths to the executable files in Windows by :
1) Running in the terminal: PATH %PATH%;C:\<new_path>
2) Creating command aliases like: doskey np=C:\<new_path>\new_command.exe $*. $* is used to be able to transmit parameters
I am running an SFTP batch to get a series of files from one unix server to another. I have a shell script that builds the batch files like:
cd path
get filename
cd path
get filename
and more.
Is there a way within SFTP to NOT run a get command if the preceding cd command fails, but keep running the rest of the batch?
To be clear, I do NOT want to terminate the whole SFTP batch, just the one get command if it's related cd command does not work.
After each cd check error code, if it is 0, everything is fine. If not, some error occured in last command...
Like:
cd directory
if [!$?]
then
get something
fi
I've tried in every way imaginable to execute a shell command from command line but it simply doesn't work. What am I doing wrong?
C:\Console2\Console.exe -r runstuff.bat
C:\Console2\Console.exe -d C:\Console2 -r runstuff.bat
C:\Console2\Console.exe -r dir
Neither works. (Win7 x64)
I am playing with that now.
Did you try:
console2 -r "/K runstuff.bat"
The /K is needed to keep the command open after running the script.
The problem I'm having with the "-r" option is that I'm having to type exit twice to leave the window.
If you add the command to shell command (settings... -> Tabs -> Shell) field you will not have to type exit twice:
%comspec% /K runstuff.bat
I don't think the "%comspec%" is necessary (could use "cmd" instead), but I got it from an example somewhere on the web years ago. Console2's included help file shows using "cmd".