garion_kong Posted June 5, 2014 Share Posted June 5, 2014 Hi, I am new to linux and was trying my first experience using cygwin on Windows 7. I am trying to run the following simple script named parsescript3 in the home directory and keeps getting the error 'syntax error near unexpected token `(''. Can anyone please help and let me know what is exactly wrong with the syntax? ~/bin/parsescript3 content #!/bin/bash FOR /F "TOKENS=1,2 DELIMS=," %%A IN ("serverA,D") DO @ECHO %%A %%B Execution and output on cygwin64: ~/bin $ ./parsescript3 ./parsescript3: line 3: syntax error near unexpected token `(' ./parsescript3: line 3: `FOR /F "TOKENS=1,2 DELIMS=," %%A IN ("serverA,D") DO @ECHO %%A %%B' Quote Link to comment https://forums.phpfreaks.com/topic/288991-getting-syntax-error-near-unexpected-token/ Share on other sites More sharing options...
requinix Posted June 5, 2014 Share Posted June 5, 2014 That's batch file syntax, for Windows. You can't use it in Cygwin, a Linux environment. Quote Link to comment https://forums.phpfreaks.com/topic/288991-getting-syntax-error-near-unexpected-token/#findComment-1481923 Share on other sites More sharing options...
garion_kong Posted June 5, 2014 Author Share Posted June 5, 2014 Hi requinix, ok, in that case what should be the correct syntax for linux then? I actually got the script from the following site http://www.systemtoolbox.com/article.php?articles_id=1023 with the full script as given below. The purpose of the script was to iterate through the server list file and maps each of the server drives that was indicated and takes a snapshot of the df information as it stands at that time. It then parses out the number of gigs used and appends it to a file named relative to server and drive letter. Unfortunately I can't even get past the 1st line. I thought it has to do with the list file so I just tried a simplified version with just the text strings but it seems it still didn't work. Please help. Your advise is much appreciated. Thanks! for /f "tokens=1,2 delims= " %%A in (drives.lst) do ( echo %%A %%B net use y: /del < y.ans net use y: \\%%A\%%B$ df -h | findstr -i y: > temp.txt type temp.txt | cut -f2 -d: | cut -f2 -dG > temp2.txt for /f %%Q in (temp2.txt) do ( echo %%Q >> %%A-%%B.txt ) del temp.txt del temp2.txt ) Quote Link to comment https://forums.phpfreaks.com/topic/288991-getting-syntax-error-near-unexpected-token/#findComment-1481927 Share on other sites More sharing options...
requinix Posted June 5, 2014 Share Posted June 5, 2014 You don't actually run that script from a Cygwin shell. Read what he actually wrote: To set up Dashboarding in Excel, we first have to collect data. Microsoft tools for disk space reporting from command line is either lacking in information or is difficult to parse. To this end, I looked to use the df command found in Linux/UNIX. This gives the info I wanted and runs easily in Windows. Simply go to http://www.cygwin.com/ to get the Cygwin version of the program. You can either install Cygwin completely locally or put it in your executable path (under My Computer > Properties > Advanced > Environmental Variables > PATH variable) or you can just download and pull out the Cygwin*.dll and the df executable. Since it consumes less space, I chose the latter option. He grabbed the df executable and put that in an accessible place. The commands there go in a regular Windows batch file, not a bash script. But ugh, that whole thing makes me feel dirty just looking at it. Disk usage information should be calculated using something like PowerShell and some WMI queries against the hosting servers. Quote Link to comment https://forums.phpfreaks.com/topic/288991-getting-syntax-error-near-unexpected-token/#findComment-1481928 Share on other sites More sharing options...
garion_kong Posted June 5, 2014 Author Share Posted June 5, 2014 Oh, ok. Unfortunately I am unable to get any response from the original site to clarify on the stuff in the article. I just wanted to have a dashboard tool to do the same thing, i.e. show all the volume utilization for various servers on a nice dashboard. I did try putting the whole script in .bat batch file but still not getting response from the script. I guess I will have to look around for a better solution. Thanks again for your responses. Quote Link to comment https://forums.phpfreaks.com/topic/288991-getting-syntax-error-near-unexpected-token/#findComment-1481929 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.