I have some SAS code that writes out to a specific sheet in an excel workbook. The other sheets have formulas that look to this sheet so the workbook is basically a template that gets populated when my code is run.
I want to be able to run the code multiple times, and end up with a different version of the template each time it is run. I'm thinking the easiest way to achieve this is write out to the template and then use x command or something to copy the workbook and then rename it.
SAS is on a linux server and I use a pc files server to write to excel. How do I set up x command to copy the file and change its name on the remote server?
Sorry for the late answer, but I just encountered this myself and can provide a solution.
Can you access files on the sas server through windows (with an SMB share or similar)? That is the easiest way to do this. If you can't, it is typically very easy to set up Samba on linux.
First, store the excel template on the SAS server where it can be seen from your windows computer (with the PC Files Server on it).
Lets say the file is in '/home/files/template.xlsx' on the SAS server, and that directory is shared and accessible on your windows server as '\linuxservername\files\template.xlsx' (or \192.168.1.5\files\template.xlsx if you are using IP addresses)
Now you just have to use the SMB path for the PCFILES stuff and the local linux path for the x command. Something like
x 'cp /home/files/template.xlsx /home/files/output.xlsx';
libname output PCFILES
path='\\linuxservername\files\template.xlsx'
server='PCFilesServerName'
port=1234;
Note that when feeding a path to PCFiles, you use the network address (since your windows box has to be able to read and write it) and when you issue the copy command, you use the local address.
You may also be able to use the network path for everything depending on your system configuration. When I tried it, I could not make it work since the unix server did not like it (it shares the folder over SMB, but it didn't know how to access it from the command line).
Related
Could you please tell me the way to get internal table data in excel file to be saved in local desktop (presentation server). Remember that the report runs in background.
Both requirements a contradictionary because a backround job does not have any connection to any SAPGui. I.e. there is no SAPGui connection linked to a background job ans thus it is not possible to determine onto which local desktop the excel file should be saved.
A possibility would be to store the results that are created in the backround job somehow and externalize the save to a local desktop into another program. When creating files on the SAP AS you should keep in mind what happens with these file after they are not needed any longer. I.e. you need to do the file maintenance (deletion of files after they are not needed any longer) your self.
Theoretically you can do this, if you create the file on a SAP AS and move this file using any shell file move command. However, it's a bad practice to make any connection from SAP AS to a user's machine.
The best solution here is to create the file on SAP AS. The user must download the file manually from the SAP AS. You can also send this file to a user for example per e-mail. The user will do no manual work in the last case.
Also a good practice is to use PI server functionality. It can deliver your file within a way the user wants to have.
My aim is to copy from a machine A(ubuntu) to remote server B(windows2012 server) using ansible copy command. I can ping the windows server machine and can even copy a small folder from ubunto to server but when the folder size becomes big it takes so so long to get copied and sometimes not get copied . I am using as follows:
-name:copy file
win_copy:
src: '/service/test.zip'
dest:'D:/test/test.zip'
test.zip folder is around 300 MB. So, win_copy is not solving my purpose. Could you suggest what can be good option in this case?
I've had this problem and just wrote a powershell script to download the file directly to a known location on the target. Write a powershell script to download the file. I would deploy the script to the target using win_copy or win_template (if you need to do substitutions) and then call it using win_command.
I have a device that stores data in an FTP-accessible folder. I can connect to it through windows (ftp:10.19.1.101) and map drive to it (C:\Users#ME#\AppData\Roaming\Microsoft\Windows\Network Shortcuts\MyDevice). There are no usernames or passwords - if the device is attached, you have access.
i can click and drag the file in Windows. I want to automate that in VBA so I can process the file.
The single file is located at the root (ftp://10.19.1.101/fs.log), and I want to copy it to a location on my C drive to process it in Excel. I've tried for hours using code snips found here to no avail. I don't access the internet to get it, and I think that might be the problem, since 99% of FTP activity is that way.
FileCopy doesn't work either.
Any help appreciated
If you can access it and map it to a drive, open up a cmd then type 'net use' and hit enter (when it's plugged in and mapped to a drive). You should then have the long location used by windows which you can use in your procedures to play around with the file?
HTH
I have created a .netrc file so i can have some macros and automatically make some standard operations inside my ftp server.
The problem is that now every time i connect to this machine it always connects with the same account automatically ,without giving me the option to select an account for this machine.
I found this question inside stackoverflow,but seems that there is no answer that can help me.
Link to similar question
Thank you all in advance
In a .netrc file, each line referring to a particular machine looks like this:
machine booster login baxter password swordfish
machine wooster login francis password sw0rdf1sh
This will define the logins for two machines: booster and wooster. If you put in a line like this:
default login root password secret
This will be used for any other machines you haven't already listed.
Macros can be defined for each machine, and are defined after the machine or default line. The macro is defined by the line macro followed by the macro name. If the name is init, that macro will be executed automatically by the system.
You need to define separate machine lines for each machine you are logging into, and then have a default line for all other machines (if so desired).
You can also tell ftp not to read in the .netrc file by doing one of the following:
$ ftp -n
You can also use another net resource file besides the default .netrc:
$ ftp -N my.netrc.file
I need to have my unmanaged VC++ program able to copy a file from the computer the application is on to one of 100 other computers.
I have administrator access on each computer, so that won't be a problem.
It seems I need to use WMI to do this, but I am having a hard time getting it to work properly by looking at examples in: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394558(v=vs.85).aspx
I am curious of the CopyFile family of functions should work:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363851(v=vs.85).aspx
This is a console application that doesn't use MFC and isn't using ATL.
Is there a good example of how to do what I am trying to do that will work on WinXP and Windows 7?
The easiest way is probably to start by creating a network connection with WNetAddConnection2, then copy the file with something like CopyFile or CopyFileEx. When you're done, it would be courteous to use WNetCancelConnection2 to remove the network connection.
The only WMI class designed to manipulate files is the CIM_DataFile class, they include a set of methods (Copy, CopyEx) to copy files but only works in the target machine, this means which you cannot copy a file from one machine to another using the WMI (at least which you use a network drive or shared).