Copying a file to sharepoint through SAS unix - unix

As a part of my work I need to create few reports in SAS and export them to sharepoint site. I am trying to automate this process as shown below.
call system ("cp -p file.xls https//sharepointsite/folder1/file.xls");
when i run this code, it is not giving any error in the code but the file not uploaded into sharepoint.
Could anyone suggest me the solution for this case.

Try the following in order to extract any errors into your log
data _null_;
infile "cp -p file.xls https//sharepointsite/folder1/file.xls" pipe;
input;
list;
run;
You can also try running the command directly from your SAS server, as a shell command. If that is successful, the above should be succesful (although I wasn't aware that uploading files to sharepoint was that straightforward).
Edit: from reading around, I think it IS possible, you just need to have your sharepoint location mapped to a local directory, and to have contributor rights on the site itself. In which case make sure you use the 'local' path for the URL..

Related

Azure Databricks: How do we access R Scripts present on DBFS?

I'm new to DataBricks. I am trying to access a .R file that is present in the DBFS storage but I cannot figure out how to do so. Any help is really appreciated.
I can read data from the storage using the file path /dbfs and also source code from the script but I want to make edits to the script.
You need some editor to do that - for example, you can setup RStudio on your cluster and connect to it via RStudio UI - in this case you can edit R files directly on DBFS.
But really, the simplest for you would be to use Databricks CLI fs command to copy the file to your local machine, make changes in the editor of your choice, and upload file back.

Is there any command to know which script.sh produced certain file in UNIX?

For example, I got in the same file like script1.sh , script2.sh then I have an output.vcf (bioinformatics stuff but is guess it doesnt matter). Then I am sure one of those scripts created the output file but i don't know which of them.
Is there any way to figure it out?
Thank you!
IMHO post factum you can't get this information. But each UNIX have own audit subsystem and if you activate it you can get which file operation (in this case file creation) is done by which program (shell script).
Actually there is a way. You can browse the scripts and search for the filename in question. There will be a problem if both scripts have this filename.

Compile PL/SQL stored procedures in SQL developer from external files

I have a requirement where I have around 50 stored procedures saved in 50 different files with .pls extension in a windows directory. I have SQL Developer installed in the same machine. I want to compile all these stored procedures in SQL developer. Note - I don't want to execute, only want to compile. Please suggest a solution for this.
I have tried this but it didn't work.
Created a compile.sql file with contents below.
##"U:\Stored_Procedures\PRC_LOAD_TBL.pls";
exit;
Created a compile.bat file with contents below.
sqlplus -s -l <username>/<pswd>#<servicename>
#"U:\Stored_Procedures\Compile.sql" ;
Tried to run compile.bat batch file but it didn't work.
Also, I tried to run these from SQL Developer directly that didn't work either.
"Tried to run compile.bat batch file but it didn't work."
You tried to run a DOS batch file in SQL Developer? I think you're over-engineering this.
All you need to do is open your first script, compile.sql in SQL Developer and then click Run script (or press F5 function key).

Unix invoke script when file is moved

I have tons of files dumped into a few different folders. I've tried organizing them several times, unfortunatly, there is no organization structure that consistently makes sense for all of them.
I finally decided to write myself an application that I can add tags to files with, then the organization can be custom to the actual organizational structure.
I want to prevent from getting orphaned data. If I move/rename a file, my tag application should be told about it so it can update the name in the database. I don't want it tagging files that no longer exist, and having to readd tags for files that used to exist.
Is there a way I can write a callback that will hook into the mv command so that if I rename or move my files, they will invoke the script, which will notify my app, which can update its database?
My app is written in Ruby, but I am willing to play with C if necessary.
If you use Linux you can use inotify (manpage) to monitor directories for file events. It seems there is a ruby interface for inotify.
From the Wikipedia:
Some of the events that can be monitored for are:
IN_ACCESS - read of the file
IN_MODIFY - last modification
IN_ATTRIB - attributes of file change
IN_OPEN and IN_CLOSE - open or close of file
IN_MOVED_FROM and IN_MOVED_TO - when the file is moved or renamed
IN_DELETE - a file/directory deleted
IN_CREATE - a file in a watched directory is created
IN_DELETE_SELF - file monitored is deleted
This does not work for Windows (and I think also not for other Unices besides Linux) as inotify does not exist there.
Can you control the path of your users? Place a script or exe and have the path point to it before the standard mv command. Have this script do what you require and then call the standard mv to perform the move.
Alternately an alias in each users profile. Have the alias call your replacement mv command.
Or rename the existing mv command and place a replacement in the same dir, call it mv and have it call your newly renamed mv command after doing what you want.

Script to recursively look for a file on ftp server until it found

I just want to transfer a file from ftp server to unix folder, --this is stright forward.
if the file doesn't exist on the ftp server, then the script needs to run recursively until it finds the file. Please let me know how do i get that file.
please remember script has to run on ftp server.
Thanks
CK
I'd mount the FTP server with curlftpfs http://curlftpfs.sourceforge.net and then use it like it were a local file system — for example, run find(1).
You need to write a program to automate your FTP session. You can either write your own custom FTP client, not that hard if you know a few things about network programming, or write a script to automate a session for an existing client. For the latter approach, I suggest using Expect if you are proficient with TCL, or PyExpect if you prefer Python. Expect is a library designed to automate interactive tasks like downloading a file with FTP.

Resources