View unanswered posts | View active topics It is currently 24 Apr 2014 09:47



Post new topic Reply to topic  [ 3 posts ] 
What is wrong with my script??? 
Author Message

Joined: 15 Aug 2012 13:15
Posts: 2
Post What is wrong with my script???
Code:
REM Changes the permission of specified file to specified Access for specified group and logs the output.
echo ------------ >> %Output%
echo ***Change*** >> %Output%
echo ------------ >> %Output%
for /f "delims=" %%y in (%Input%) do (
echo icacls %%y /grant:r %Group%:(%Permission%) >> %Output%
icacls %%y /grant:r %Group%:(%Permission%) 2>> %Output%
)
echo. >> %Output%

And the output that gets displayed is:

Code:
------------
***Change***
------------
icacls C:\Test_File.txt /grant:r EVERYONE:(F
icacls C:\Test_File_2.txt /grant:r EVERYONE:(F
%y: The system cannot find the file specified.


I can't figure out why it's not using the value from the file that it should be pulling.

Thanks for any help


15 Aug 2012 13:20
Profile
Expert

Joined: 12 Feb 2011 21:02
Posts: 1120
Location: United States (east coast)
Post Re: What is wrong with my script???
You have 2 places in your code where you have ) character that is not escaped and not quoted, so it is ending your code block prematurely.

You just need to escape the ) characters.
Code:
REM Changes the permission of specified file to specified Access for specified group and logs the output.
echo ------------ >> %Output%
echo ***Change*** >> %Output%
echo ------------ >> %Output%
for /f "delims=" %%y in (%Input%) do (
  echo icacls %%y /grant:r %Group%:(%Permission%^) >> %Output%
  icacls %%y /grant:r %Group%:(%Permission%^) 2>> %Output%
)
echo. >> %Output%


Dave Benham


15 Aug 2012 15:36
Profile

Joined: 15 Aug 2012 13:15
Posts: 2
Post Re: What is wrong with my script???
Quote:
You have 2 places in your code where you have ) character that is not escaped and not quoted, so it is ending your code block prematurely.

You just need to escape the ) characters.



Thanks a lot! That solved my problem :D


16 Aug 2012 07:37
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.