In this code
I'd like to delete the line 2207 and 2208.
I tried several replace actions in the "Search & Replace" tools but none works
\r\n WriteDumbowLog("MethodName:" & methodName)"
"\n\r WriteDumbowLog("MethodName:" & methodName)"
".$ WriteDumbowLog("MethodName:" & methodName)"
"\n WriteDumbowLog("MethodName:" & methodName)"
The correct regular expression is:
((\r\n)|\n|\r) WriteDumbowLog\("MethodName\:" & methodName\)
I used this extension https://marketplace.visualstudio.com/items?itemName=PeterMacej.MultilineSearchandReplace which doesn't work (oddly) but provide you the correct regex to replace.
Related
I'm using SSIS in conjunction with WinSCP to push a file. Everything seemed to be going OK, but I'm getting an error. It looks like SSIS is, at some point, putting a "phantom space" into my variable for some reason.
The variable is set up like this:
"/command \"open sftp://" + #[User::SFTP_User]+":"+ #[User::SFTP_Pass] + "#" + #[User::SFTP_Site] + " -hostkey=\"\"ssh-rsa 2048 "+ #[User::SFTP_Hostkey] +"\"\"\" \"put -nopreservetime "+ #[User::InventoryFile] + " " + #[User::PurchaseFile] + " " + #[User::SFTP_Location] + "\" \"exit\""
and is used as the script string for WinSCP.com.
When I take the computed value and copy it into Notepad++, I get something like
/command "open sftp://USER:Pas$word#ftp.site.com -hostkey=""ssh-rsa 2048 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00""" "put -nopreservetime \\my\path\file.csv \\my\path\file2.csv /remote/path/" "exit"
HOWEVER!!! Copying/pasting this to the command line, rather than notepad++, however, yields
/command "open sftp://USER: Pas$word#ftp.site.com -hostkey=""ssh-rsa 2048 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00""" "put -nopreservetime \\my\path\file.csv \\my\path\file2.csv /remote/path/" "exit"
ALSO!!! when I run the package, I get an error message:
Error: 0xC0029151 at WinSCP Files to MSA, Execute Process Task: In Executing "C:\Program Files (x86)\WinSCP\WinSCP.com" "/command "open sftp://USER: Pas$word#ftp.site.com -hostkey=""ssh-rsa 2048 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00""" "put -nopreservetime \\my\path\file.csv \\my\path\file2.csv /remote/path/" "exit"" at "\\my\working\path\", The process exit code was "1" while the expected was "0".
Please notice that there is an extra " " (space) in between the "USER:" and the password. This is breaking the command. Also notice that there is an extra space in between the upload files and the upload location (however, this does not seem to have any ill effect). If I copy that whole thing to a command prompt and just remove that space after the colon, it works...
Where are these phantom spaces coming from and/or how do I get rid of them?
I was able to solve this by going into Notepad++ and using the "HEX Editor" plugin to see the hidden characters.
Even "Show all characters" was not showing the hidden characters...
I'm sure that they came from copying from formatted text into the variable. It was really strange that in some instances you could copy/paste them without the formatting and in other circumstances the hidden characters would be there. I usually use notepad++ as a tool (intermediate copy/paste) for removing formatting, but it was not removing these devils.
Anyway, once I found the hidden characters in the HEX editor, I was able to simply remove them from there, switch back to ASCII mode, copy the string and paste it back into the SSIS program and go from there. Problem solved!
Thanks all - your ideas helped get me to the solution.
I want to package a project of mine for windows with CPack and NSIS using an already existing
GeneratorConfig.cmake file where I want to add an extra command that will copy an .ini file called myProject.ini into %APPDATA%/myProject/myProject.ini .
This is GeneratorConfig.cmake
SET(INSTALL_AN_ALREADY_EXISTING_DIR ".")
##########################################################################
## Begin NSIS Specific options
##------------------------------------------------------------------------
if(CPACK_GENERATOR MATCHES NSIS)
# Additional NSIS commands to uninstall start menu shortcuts
SET(CPACK_NSIS_DELETE_ICONS_EXTRA
"Delete \"$SMPROGRAMS\\$MUI_TEMP\\${PROJECT_NAME}.lnk\"
StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2
Delete \"$DESKTOP\\${PROJECT_NAME}.lnk\" ")
# The display name string that appears in the Windows Add/Remove Program control panel
SET(CPACK_NSIS_DISPLAY_NAME "${PROJECT_NAME} ${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}")
SET(CPACK_NSIS_DISPLAY_NAME_SET "TRUE")
# Extra NSIS commands that will be added to the end of the install Section, after your
# install tree is available on the target system.
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
"CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\${PROJECT_NAME}.lnk\" \"$INSTDIR\\.\\bin\\${PROJECT_EXE} \" -previousworkingdir \"$INSTDIR\\.\\bin\\app_icon.ico\"
StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2
CreateShortCut \"$DESKTOP\\${PROJECT_NAME}.lnk\" \"$INSTDIR\\.\\bin\\${PROJECT_EXE} \" -previousworkingdir \"$INSTDIR\\.\\bin\\app_icon.ico\"
")
# Extra commands to fix permissions of bin/licenses folder
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
"${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}
ExecWait 'icacls \\\"$INSTDIR\\\\bin\\\\licenses\\\" /grant:r Users:\\\(OI\\\)\\\(CI\\\)\\\(F\\\)'
")
# A path to the executable that contains the installer icon.
SET(CPACK_NSIS_INSTALLED_ICON_NAME "${PROJECT__DIR}\\bin\\${PROJECT_EXE}")
# The default installation directory presented to the end user by the NSIS installer
SET(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
# Title displayed at the top of the installer
SET(CPACK_NSIS_PACKAGE_NAME "${PROJECT_NAME} ${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}")
SET(CPACK_NSIS_PAGE_COMPONENTS " ")
SET(CPACK_NSIS_MUI_FINISHPAGE_RUN ${PROJECT_EXE})
endif(CPACK_GENERATOR MATCHES NSIS)
##------------------------------------------------------------------------
## End NSIS Specific options
##########################################################################
I tried to do this with the code below but this builds the package but doesn't
copy myProject.ini anywhere.
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
"CreateDirectory \"$ENV{APPDATA}\\myProject\",
SetOutPath \"$ENV{APPDATA}\\myProject\",
File \"myProject.ini\"
")
Any help or suggestions will be appreciated.
From what i can tell you are using not enough '\' symbols.
To clarify: that string is evaluated twice, once by CMake and once by CPack, and each time substitutions such as \->\ and \" -> " occur. Please check generated nsis project for what the actual generated commands are and whether all '"' are correctly set.
To summarize: try using this:
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
"CreateDirectory \\\"$ENV{APPDATA}\\\\myProject\\\",
SetOutPath \\\"$ENV{APPDATA}\\\\myProject\\\",
File \\\"myProject.ini\\\"
")
When using Word for Mac 2011 and Tools → Macro → Record New Macro to record a VBA macro for inserting a picture via Insert → Photo → Picture from File the picture will be inserted in your document during recording, but you will end up with a non-functional macro like this one:
Sub NotWorkin()
'
' NotWorkin Visual Basic for Applications Macro
'
'
Selection.InlineShapes.AddPicture fileName:= _
"/Users/mark/SMPTE_RP_219_2002.png", LinkToFile:=False, SaveWithDocument _
:=True
Selection.InlineShapes.AddPicture fileName:="", LinkToFile:=False, _
SaveWithDocument:=True
End Sub
When you try to run the macro it will throw an error:
Run-time error '5152':
This is not a valid file name.
Try one or more of the following:
* Check the path to make sure it was typed correctly.
* Select a file from the list of files and folders.
This was tested with OS X (Version 10.8.5) and
Microsoft® Word for Mac 2011,
Version 14.4.3 (140616),
Latest Installed Update: 14.4.3
What is happening here and why is the macro not working ?
It seems the macro recorder generates quite buggy code in this case. It inserts two code blocks where the second one has an empty file name, the complete second block can be deleted :
Selection.InlineShapes.AddPicture fileName:="", LinkToFile:=False, _
SaveWithDocument:=True
Then there is a nasty bug in the macro recorder leading to slashes instead of colons in the string for fileName in the first code block:
"/Users/mark/SMPTE_RP_219_2002.png"
where the correct format for Word for Mac 2011 on OS X has to be:
"Users:mark:SMPTE_RP_219_2002.png"
A working code would here be:
Sub Workin()
'
' Workin Visual Basic for Applications Macro
'
'
Selection.InlineShapes.AddPicture fileName:= _
"Users:mark:SMPTE_RP_219_2002.png", LinkToFile:=False, SaveWithDocument _
:=True
End Sub
If you link to the pictures instead of embedding them and then use VBA to get the paths of all linked images in a document, the path strings will also be formatted using slashes instead of colons:
Sub DebugPrintInlineImageNames()
On Error Resume Next
For Each InlineShape In ActiveDocument.InlineShapes
Debug.Print (InlineShape.LinkFormat.SourceFullName)
Next InlineShape
These strings have to be converted so that VBA can find the files, simplest example:
ILpath = "/Users/mark/SMPTE_RP_219_2002.png" ' example path
Colpath = Replace(ILpath, "/", ":") ' replace all slashes by colons
FixPath = Mid(Colpath, 2, Len(Colpath) - 1) ' remove fist char, ie prefixed colon
Thus, if you receive a Run-time error '5152': This is not a valid file name, make sure your file name is formatted correctly: colons instead of slashes for Office 2011 on OS X
Once upon a time, it was possible to put file:// urls into webpages, and if that URL matched a file on your desktop, why, the file would open on your computer when you clicked on the link.
This functionality has been disabled for security reasons, but I'm trying to recreate it for my own personal use. I'm trying to use a custom URL protocol and an Applescript application as described at http://www.macosxautomation.com/applescript/linktrigger/. I've almost got it working, with one difficulty: A URL can't have spaces in it, so they get escaped, as do other special characters like "&". How can I convince Applescript to open a file with a path with escaped characters in it, such as "/Users/jim/Dropbox/Getting%20Started.pdf"?
tell application "Finder"
open "/Users/jim/Dropbox/Getting Started.pdf" as POSIX file
works fine, whereas
tell application "Finder"
open "/Users/jim/Dropbox/Getting%20Started.pdf" as POSIX file
fails.
Is there an easy (i.e. non-regex) way to make this work?
You can use the open command in do shell script.
Like this:
set tUrl to "/Users/jim/Dropbox/Getting%20Started.pdf"
do shell script "open 'file://" & tUrl & "'"
Try the following:
tell application "Finder"
open my decodeFromUri("/Users/jim/Dropbox/Getting%20Started.pdf") as POSIX file
end tell
after declaring the following handler:
(*
Decodes a string previously encoded for inclusion in a URI (URL).
Note: Uses Perl and its URI::Escape module (preinstalled as of at least OSX 10.8).
Adapted, with gratitude, from http://applescript.bratis-lover.net/library/url/
Example:
my decodeFromUri("me%2Fyou%20%26%20Mot%C3%B6rhead") # -> "me/you & Motörhead"
*)
on decodeFromUri(str)
if str is missing value or str = "" then return str
try
# !! We MUST use `-ne` with `print` rather than just `-pe`; the latter returns the input unmodified.
return do shell script "printf '%s' " & quoted form of str & " | perl -MURI::Escape -ne 'print uri_unescape($_)'"
on error eMsg number eNum
error "Decoding from URI failed: " & eMsg number eNum
end try
end decodeFromUri
with the most kind help of an expert, I was able to achieve my target of
1) automatically creating a folder structure based on entry in Column 3; and
2) automatically creating a hyperlink in the appropriate column
The code can be found below
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Columns(3)) Is Nothing Then
Dim tr As String
With Target
tr = ThisWorkbook.Path & "\" & .Offset(, -2).Value
If Len(Dir(tr)) = 0 Then
MkDir tr
MkDir tr & "\Subfolder 1"
MkDir tr & "\Subfolder 2"
MkDir tr & "\Subfolder 3" & "\Sub-subfolder 1"
.Hyperlinks.Add .Offset(, 4), tr, TextToDisplay:="Name"
End If
End With
End If
End Sub
I have been trying to get this to work on Mac but I always get and error 68 and then debugger opens on line
If Len(Dir(tr)) = 0 Then
I have tried changing the \ within inverted commas in the line below
tr = ThisWorkbook.Path & "\" & .Offset(, -2).Value
to
using :
using \
using " " (basically empty space)
I tried changing "(denominator)" to application.pathseparator - still nothing.
Absolutely nothing.
The user has kindly suggested this webpage http://www.rondebruin.nl/mac.htm#Directory
(see section Make a director when it does not exist) which might indeed work - the problem I see with that is that it does not seem to check if a folder already exists and also I am not quite clear on how I would create the sub-folders.
But for some (stubborn/silly?) reason, I am convinced that this must work somehow and I am over-complicating life.
Any thoughts?
Luke
On Mac, you should use forward slash, /.
Since you do not really know whether you're on a PC or a Mac, I suggest to use the filesystem object instead of shell calls you referred to because doing that you would also need to know whether you're calling a windows command line or mac bash script. They're not the same. : )
Here it is described: http://www.tek-tips.com/faqs.cfm?fid=4116