- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: copy_files_in_dir.sh[12]: Syntax error at line...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011 04:43 PM
02-15-2011 04:43 PM
copy_files_in_dir.sh[12]: Syntax error at line 35 : `(' is not expected
I am trying to run the file 'copy_files_in_dir.sh' and getting the error that - `(' is not expected. Could somebody help me please. Below is the content at line # 35.
mondate_pd=$echo $var | awk '{ printf "%s\n", substr( $1, 6, 6 ) }'
Please let me know if I need to provide more details.
Thanks & Regards,
Dhiraj
- Tags:
- quoting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2011 10:24 AM
02-16-2011 10:24 AM
Re: copy_files_in_dir.sh[12]: Syntax error at line 35 : `(' is not expected
You want:
mondate_pd=$(echo $var | awk '{ printf "%s\n", substr( $1, 6, 6 ) }')
...in order to set the 'mondae_pd' variable. Notice the $(...)
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2011 10:31 AM
02-16-2011 10:31 AM
Re: copy_files_in_dir.sh[12]: Syntax error at line 35 : `(' is not expected
Thanks & Regards,
Dhiraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2011 10:39 AM
02-16-2011 10:39 AM
Re: copy_files_in_dir.sh[12]: Syntax error at line 35 : `(' is not expected
There is nothing wrong with the corrected syntax I offered.
I should point out that the shell's reporting of the line number at which an error occurs is somewhat fuzzy. Generally, the error is reported a few lines after the real problem.
You can better expose things by running your script with tracing:
# sh -x ./myscript 2>&1|more
If you post your whole script it would be easier to resolve, too.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2011 10:45 AM
02-16-2011 10:45 AM
Re: copy_files_in_dir.sh[12]: Syntax error at line 35 : `(' is not expected
Thanks again.
Kind Regards,
Dhiraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2011 11:29 AM
02-16-2011 11:29 AM
Re: copy_files_in_dir.sh[12]: Syntax error at line 35 : `(' is not expected
Your script appears to have been mangled. The first problem is:
ls -ltr | grep : | grep -v "^d" | awk '{ print $6 "-" $7 " " $8 " " $9 }' | awk '//
...which occurs at line-24. There is no continuation of the last 'awk' script nor is the line itself continued
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2011 12:07 PM
02-16-2011 12:07 PM
Re: copy_files_in_dir.sh[12]: Syntax error at line 35 : `(' is not expected
Thanks for your time to help me.
Kind Regards,
Dhiraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2011 01:50 PM
02-16-2011 01:50 PM
Re: copy_files_in_dir.sh[12]: Syntax error at line 35 : `(' is not expected
I found that in line 24, awk comand is required at the end since its followed by if else clause. There is awk '// at the end of line 24 but I guess only awk ' is required so I removed '//' part and ran the file but again same error. I am learning new things and trying to debug it again :). will let you if I find anything else till tomorrow.
Thanks & Regards,
Dhiraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2011 08:52 AM
02-17-2011 08:52 AM
Re: copy_files_in_dir.sh[12]: Syntax error at line 35 : `(' is not expected
I tried to get something out of the script but still I am getting the same error. Can you please help me out
Thanks & Regards,
Dhiraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2011 10:51 AM
02-17-2011 10:51 AM
Re: copy_files_in_dir.sh[12]: Syntax error at line 35 : `(' is not expected
> I tried to get something out of the script but still I am getting the same error. Can you please help me out
OK, disregard what I said originally. This is one seriously convoluted script.
Using the last post of your code. Change these lines as shown:
Change lines 35-36 from:
mondate_pd=$(echo $var | awk '{ printf "%s\n", substr( $1, 6, 6 ) }')
curr_yr=$echo `date -u` | awk '{ print $6}'
...to this:
mondate_pd=echo $var | awk '{printf "%s\n",substr\($1,6,6\)}'
curr_yr=echo `date -u` | awk '{ print $6}'
...and see if this solves your problem.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2011 11:29 AM
02-17-2011 11:29 AM
Re: copy_files_in_dir.sh[12]: Syntax error at line 35 : `(' is not expected
copy_files_in_dir.sh[12]: .: A test command parameter is not valid.
Usage: scp [options] [[user@]host1:]file1 [...] [[user@]host2:]file2
Options:
-1 Forces scp to use protocol 1.
-2 Forces scp to use protocol 2.
-4 Forces scp to use IPv4 addresses only.
-6 Forces scp to use IPv6 addresses only.
-B Selects batch mode (prevents asking for passwords or passphras-es).
-C Compression enable.
-c cipher Selects the cipher to use for encrypting the data transfer.
-F ssh_config Specifies an alternative per-user configuration file for ssh.
-i identity_file Selects the file from which the identity(private key)for RSA authentication is read.
-l limit Limits the used bandwidth, specified in Kbit/s.
-o ssh_option Used to pass options to ssh in the format used in ssh_config file.
-P port Specifies the port to connect to on the remote host.
-p Preserves modification times, access times, and modes from the original file.
-q Disables the progress meter.
-r Recursively copy entire directories.
-R buf.size Specify receive buffer size.
-S program Name of program to use for the encrypted connection.
-v Verbose mode.
Thanks & Regards,
Dhiraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2011 11:48 AM
02-17-2011 11:48 AM
Re: copy_files_in_dir.sh[12]: Syntax error at line 35 : `(' is not expected
> Sorry but I get the following error after I replaced those 2 lines-
>copy_files_in_dir.sh[12]: .: A test command parameter is not valid.
>Usage: scp [options] [[user@]host1:]file1 [...] [[user@]host2:]file2
Errors such as these arise from poor programming practices. You have statements like:
if [ $2 = "." -o $2 = "s14139/" -o $2 = "s14041/" ]
...which is $2 isn't defined, generate an error. You need to protect against this misbehavior by quoting :
if [ "$2" = "." -o "$2" = "s14139/" -o "$2" = "s14041/" ]
Regards!
...JRF...