cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1976
Views
0
Helpful
8
Replies

How to run a for loop windows command in Tidal

xuzhang01
Level 1
Level 1

I tried to call a windows cmd of for loop like this:


for /f %a in ('dir \\server1\folder1 /b /o:-d') do copy \\server1\folder1\%a \\server2\folder2\ & exit

 

But the result is that Tidal won't execute the dir command within the for loop, but retrieve 'dir' as the return value of the first loop. Because the tidal job failed with output: cannot find \\server1\folder1\dir

 

Any thoughts?

8 Replies 8

Did you try enclosing the same command in a batch script and call the batch script from Tidal ?

You may also consider using PowerShell script to do the same task and see if it works

We are not allowed to run script on that server, but lony call cmd...

1. Does the Windows server have PowerShell installed ?

2. Look like you are trying to copy all the files in a directory to another. Do you really need a loop here ? Sorry if I am not reading the requirement correctly

3. Is robocopy installed on the agent Windows machine ?

1. Does the Windows server have PowerShell installed ?

                Nope :-(

2. Look like you are trying to copy all the files in a directory to another. Do you really need a loop here ? Sorry if I am not reading the requirement correctly

               No, I am only copying the newest file in the folder into the target folder, that's why I need a dir to list all files ordered by update time.

3. Is robocopy installed on the agent Windows machine ?

               No :-(

Also, if you are using Windows Sever 2008, the PowerShell and robocopy should be available by default as part of the OS.

The following works for me. You can improvize to suit your need.

In the windows job you give

Command as : cmd.exe

Command Parameters/c forfiles /p E:\Scripts /m *.* /c "cmd /c echo @file"

(this job will return all the files under e:\scripts)

Derrick Au
Level 4
Level 4

Hi xuzhang01,

 

Please verify if agent is running under a domain service account or as local system. If local system then it will not be able to access network resources, and you will need to run under as domain service account with permissions to that network share.

 

BR,

Derrick Au

Dave.Carnahan
Level 1
Level 1

Test for access permissions on these servers 1st before you try and send something to them.

Too bad you don't try using PowerShell to attempt these activities, because PowerShell contains the Try, Catch Finally construct your job need in this example, just like C# and other languages, but it's a plain script file, like Perl.

The portion in this pic (attached) shows the construct of testing for access with the default credentials.

--

Remember,

  1. Shares can have credentials one day, and the next, the shares gone!
  2. And then, the folder & it's parent folder can be renamed or removed on you accidentally or on purpose.
  3. Then whether Directory Services is able to keep up with activities on the server if a service or job is consuming the server
  4. Then finally, can you Ping the server on the network at all and/or do your routers know how to find their way to the server?

-

That's ours,

We have a situation where we run (on the stack) at the top for data replication of files, but someone else owns the share and another maintains the actual server AND a different organization maintains the network and firewalls between the two servers.

=> Look at the total stack when you ask your questions and ask if you've addressed all the angles.

Also, a version of Microsoft PowerShell runs on every server Microsoft makes except Win2000 servers, but you'd better hurry and at least get up to Windows 2008R2 if you want support.

Review Cisco Networking for a $25 gift card