Can we create a folder in tmp location using javascript or any other way? | Community
Skip to main content
Sanket_Phawde
New Participant
March 27, 2019
Solved

Can we create a folder in tmp location using javascript or any other way?

  • March 27, 2019
  • 1 reply
  • 1936 views

Hi,

Want to create a folder in the tmp location, How can we create it? javascript or any other way to create the folder?. And after creating the folder want to push some exported packages in that folder and then zip the folder.

Regards,

Sanket Phawde

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Florian_Courgey

Hi,

you can use the standard linux API:

var folder = execCommand('mktemp -d', true); // [0, "/tmp/tmp.0351385kt "]

folder = folder[1].trim(); // remove any whitespace

logInfo('folder '+folder);

execCommand('touch '+folder+'/myfile1', true); // create some files in the folder

execCommand('touch '+folder+'/myfile2', true);

var zip = execCommand('zip '+folder+'/myzip.zip '+folder); // [0, ""]

logInfo(zip[1]);

var ls = execCommand('ls -alh '+folder); // [0, "myfile1 myfile2 myzip.zip"]

logInfo(ls[1]);

Reference:

- Linux zip https://linux.die.net/man/1/zip

- Linux mktemp https://linux.die.net/man/1/mktemp

- ACC execCommand

1 reply

Florian_Courgey
Florian_CourgeyAccepted solution
New Participant
March 27, 2019

Hi,

you can use the standard linux API:

var folder = execCommand('mktemp -d', true); // [0, "/tmp/tmp.0351385kt "]

folder = folder[1].trim(); // remove any whitespace

logInfo('folder '+folder);

execCommand('touch '+folder+'/myfile1', true); // create some files in the folder

execCommand('touch '+folder+'/myfile2', true);

var zip = execCommand('zip '+folder+'/myzip.zip '+folder); // [0, ""]

logInfo(zip[1]);

var ls = execCommand('ls -alh '+folder); // [0, "myfile1 myfile2 myzip.zip"]

logInfo(ls[1]);

Reference:

- Linux zip https://linux.die.net/man/1/zip

- Linux mktemp https://linux.die.net/man/1/mktemp

- ACC execCommand