LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-08-2013, 05:49 AM   #1
Celtic Yokel
Member
 
Registered: Feb 2013
Location: Knighton, Powys, Mid Wales
Distribution: Linux Mint
Posts: 41

Rep: Reputation: Disabled
Smile bash: syntax error near unexpected token `('


I'm new to Linux, and had the command line forced on me by a problem getting Ubuntu 12.04 to boot on a hard-disk intended to dual-boot with XP which is on another disk. Working with a live-cd, I've found out how to get into the terminal and, having downloaded various bits of information, I'm enjoying finding out what I can do with it, but I've got stuck at bash: syntax error near unexpected token `(' .I've read the answers to the similar threads, but my knowledge is so little that I was none the wiser. I don't have internet access at home and am reliant on access from my local library, so if anyone gives me some advice, or asks for further info, I may be several days getting back to you - but I will do!
 
Old 02-10-2013, 08:11 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by Celtic Yokel View Post
I'm new to Linux
Welcome to LQ, hope you like it here.


Quote:
Originally Posted by Celtic Yokel View Post
I've got stuck at bash: syntax error near unexpected token `('
The problem is we don't know what command you executed.


Quote:
Originally Posted by Celtic Yokel View Post
getting Ubuntu 12.04 to boot on a hard-disk intended to dual-boot with XP which is on another disk.
If XP is on another hard disk then you can save yourself a lot of time by just disconnecting the power cable from that disk. Then the installer will only see the remaining hard disk so you can't make the mistake of installing Ubuntu on the wrong disk. Unless you disconnect the wrong one of course.
 
Old 02-12-2013, 05:10 AM   #3
Celtic Yokel
Member
 
Registered: Feb 2013
Location: Knighton, Powys, Mid Wales
Distribution: Linux Mint
Posts: 41

Original Poster
Rep: Reputation: Disabled
Good morning, everyone
Unspawn, thank you for the replies to my original thread. I'm confident that I'm not in danger of installing on the wrong disk. Would installing with only one disk attached still dual-boot when I reattached the other disk? I view this as a challenge to get it working now, and I've been doing a bit of homework since I posted that, with the following results:

Disk & Partition info according to Gparted
Partition File System Label Size Used Flags
/dev/sda (38.35Gb)
/dev/sda1 Fat 16 Dell Utility 31.35Mb 1.44Mb diag
/dev/sda2 ! Ntfs 37.21Gb boot
Unallocated 1.10Gb
/dev/sdb (9.50Gb)
/dev/sdb1 Ntfs 5.36Gb 28Mb boot
/dev/sdb2 Extended 4.14Gb
/dev/sdb6 Ext 4 3.39Gb 2.08Gb
/dev/sdb5 Linux-swap 766Mb

ubuntu@ubuntu:~$ set pager=1
ubuntu@ubuntu:~$ uname -a
Linux ubuntu 3.2.0-29-generic-pae #46-Ubuntu SMP Fri Jul 27 17:25:43 UTC 2012 i686 i686 i386 GNU/Linux
ubuntu@ubuntu:~$ sudo update-grub
/usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?).
ubuntu@ubuntu:~$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
ubuntu@ubuntu:~$ grub> ls /
The program 'grub' is currently not installed. You can install it by typing:
sudo apt-get install grub
ubuntu@ubuntu:~$ sudo apt-get install grub
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
grub-legacy-doc mdadm
The following packages will be REMOVED:
grub-gfxpayload-lists grub-pc grub2-common
The following NEW packages will be installed:
grub
0 upgraded, 1 newly installed, 3 to remove and 0 not upgraded.
Need to get 330 kB of archives.
After this operation, 212 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Err http://archive.ubuntu.com/ubuntu/ precise/main grub i386 0.97-29ubuntu66
Could not resolve 'archive.ubuntu.com'
Failed to fetch http://archive.ubuntu.com/ubuntu/poo...ntu66_i386.deb Could not resolve 'archive.ubuntu.com'
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
ubuntu@ubuntu:~$ --fix-missing?
--fix-missing?: command not found
ubuntu@ubuntu:~$ ls /
bin dev initrd.img mnt rofs sbin sys var
boot etc lib opt root selinux tmp vmlinuz
cdrom home media proc run srv usr
ubuntu@ubuntu:~$ ls /boot
abi-3.2.0-29-generic-pae grub memtest86+_multiboot.bin
config-3.2.0-29-generic-pae memtest86+.bin System.map-3.2.0-29-generic-pae
ubuntu@ubuntu:~$ ls /boot/
abi-3.2.0-29-generic-pae grub memtest86+_multiboot.bin
config-3.2.0-29-generic-pae memtest86+.bin System.map-3.2.0-29-generic-pae
ubuntu@ubuntu:~$ ls/boot/grub
bash: ls/boot/grub: Not a directory
ubuntu@ubuntu:~$ ls /boot/grub
gfxblacklist.txt grubenv
ubuntu@ubuntu:~$ ls (hd1,6)/boot/grub/
bash: syntax error near unexpected token `('

I hope this is more informative! If all fails I shall install Ubuntu as a single os.
 
Old 02-12-2013, 05:24 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
ls (hd1,6)/boot/grub/ definitely will cause a syntax error, as it was reported. That is normal. Why did you want to do that? What do you want to achieve? be care, you can easily destroy your OS!
 
Old 02-13-2013, 04:41 AM   #5
Celtic Yokel
Member
 
Registered: Feb 2013
Location: Knighton, Powys, Mid Wales
Distribution: Linux Mint
Posts: 41

Original Poster
Rep: Reputation: Disabled
Smile

Thank you for your reply, Pan64
I wasn't trying to achieve anything in particular, just gathering information which would be useful for anyone that was able to advise me on how to get the dual-boot working.
 
Old 02-13-2013, 06:49 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by Celtic Yokel View Post
I hope this is more informative!
It is but some pieces of the puzzle are missing.


Quote:
Originally Posted by Celtic Yokel View Post
If all fails I shall install Ubuntu as a single os.
You already have Ubuntu installed on the "second" disk in the /dev/sdb6 partition and generally there is no need to keep installing it once you have it ;-p


Quote:
Originally Posted by Celtic Yokel View Post
Would installing with only one disk attached still dual-boot when I reattached the other disk?
Generally speaking, yes. In short with the BIOS set to boot from the (MBR of the) first disk /dev/sda it would boot windows.
- If you installed Ubuntu on the second disk without the first disk attached then it would install its own bootloader code in the MBR of /dev/sdb (which it would see as /dev/sda because there's no other disk attached at installation time) or in the partition where Ubuntu is installed (though you probably had to explicitly tell the installer to do so). After reconnecting /dev/sda Ubuntu wouldn't load and you'd have to 0) use the installer CD in rescue mode to correct /boot/grub/grub.conf to use the right root device "root (hd1,5)" and 1) set up EasyBCD in windows to give you the choice to boot between windows and Linux.
- If you installed Ubuntu on the second disk with the first disk attached but installed its bootloader in the root of the disk where Ubuntu is installed you could use GRUB to swap devices virtually with "map (hd0) (hd1); map (hd1) (hd0)".
- If you installed Ubuntu on the second disk with the first disk attached then having it install its own bootloader code in the partition where Ubuntu is installed would keep you from having to mess with windows not booting. Then you would set up EasyBCD in windows to give you the choice to boot between windows and Linux.

* Please read:
https://help.ubuntu.com/community/Wi..._after_Windows
https://help.ubuntu.com/community/Wi...d_Boot_Manager.

So the question is what did you do? Did you
0) install Ubuntu with both disks attached or not and
1) where did you install the bootloader?

Last edited by unSpawn; 02-13-2013 at 06:53 AM.
 
1 members found this post helpful.
Old 02-14-2013, 05:09 AM   #7
Celtic Yokel
Member
 
Registered: Feb 2013
Location: Knighton, Powys, Mid Wales
Distribution: Linux Mint
Posts: 41

Original Poster
Rep: Reputation: Disabled
Good morning, everyone
That sounds very helpful, unSpawn; I've copied the advice and shall go home and play! I originally had 2 hd's installed, one with XP and the other with Ubuntu 11.04 (which I had no difficulty installing), but the Linux disk kept flashing up 'Disk failure is imminent'so I replaced it with the 9Gb disk before installing 12.04 from a live cd, with both disks attached. Should the bootloader have been installed as a separate operation? I expected it to be automatic from the cd.
 
Old 02-14-2013, 05:58 AM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by Celtic Yokel View Post
Should the bootloader have been installed as a separate operation? I expected it to be automatic from the cd.
Partitioning, formatting, installing are in fact all separate operations: it's the installer that makes it seem seamless. So the bootloader is installed automagically though before it does you'll usually have the option to customize it. The question is where it is installed. There's probably an easier way to find out:
Code:
awk '/[h,s]d[a-z].*[0-9]/ {print $NF}' /proc/partitions | while read PART; do
  dd bs=512 count=1 if=/dev/${PART} 2>/dev/null|grep -qa -m1 GRUB && echo $part
done
 
Old 02-14-2013, 07:53 AM   #9
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Playing with disks (eg de-activating and re-activating them, changing their order in BIOS) between the installs of operating systems is a bad idea; one or two of your OS's will be confused, possibly un-bootable.
Install Windows first, then linux, and let grub/lilo be intalled into the MBR of the first disk; it will give you a nice menu boot-time to choose between the two OS's.

Edit:
A suggestion for people with more than one HDD: when installing Windows, it uses the first HDD; don't let it use the whole disk though; at least a 'boot' partition of linux should be created on the first HDD to put lilo/grub boot-loader into it (a little part of the boot-loader goes into the MBR (called 'stage 1'), the other part ('stage 2') goes somewhere else, in lilo's case: /boot/map), otherwise removing the second (third...) HDD that have partition /boot on it makes the boot-loader unusable, so you couldn't use Windows either.

Last edited by NevemTeve; 02-14-2013 at 10:01 AM.
 
Old 02-14-2013, 09:16 AM   #10
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
ubuntu@ubuntu:~$ ls (hd1,6)/boot/grub/
bash: syntax error near unexpected token `('
The direct answer to your original question is that you are mixing the syntaxes required by two different environments. The Linux program 'ls' requires you to supply filesystem names (it doesn't know about disks and partitions, only the filesystem). The bootloader 'grub', on the other hand needs to know about disks and partitions, so it has a syntax that allows you to express those things. One is a program that runs on Linux, while the other is a program that is loaded by the lowest level code in the computer at boot time, and only knows how to start an OS.
It is common to associate grub with Linux, and so you might make an argument that the syntaxes used by each should be the same. However, grub is really OS agnostic, being able to load any number of OSs. It doesn't necessarily follow that it should mimic the behavior of any particular OS.

I like to do as NevemTeve suggests, installing Windows first on the only drive. Then, make the Windows drive the 'second' drive, and install Linux on the 'first' drive. To boot Windows, use the grub map command to virtually swap drives at boot time. Then when Windows wants to update its own bootloader, it won't trash the grub bootloader on the real boot disk. This also allows you to relocate the Windows disk to another host as a standalone Windows drive, or remove the Linux drive and boot solely as a Windows host. Haven't done this since Windows XP, so if newer Windows versions won't work this way, I let someone else speak to that.

--- rod.
 
Old 02-14-2013, 10:05 AM   #11
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by NevemTeve View Post
Install Windows first, then linux
Quote:
Originally Posted by theNbomr View Post
I like to do as NevemTeve suggests, installing Windows first on the only drive.
Here's a recap of this thread (IIRC):
He has windows installed already so there's no need to suggest he should install it again.
He then replaced and installed Ubuntu on the 2nd disk.
So he has Linux installed already and there definitely is no need to suggest he installs it again.
So AFAIK the only thing here is to fix GRUB.

Last edited by unSpawn; 02-14-2013 at 10:06 AM.
 
Old 02-15-2013, 04:45 AM   #12
Celtic Yokel
Member
 
Registered: Feb 2013
Location: Knighton, Powys, Mid Wales
Distribution: Linux Mint
Posts: 41

Original Poster
Rep: Reputation: Disabled
My thanks to you all that have posted advice. I've copied it all, and will study and act on it over the w/e. I shan't be on the internet now until Tuesday at the earliest.
Have a good weekend, everyone
 
Old 02-19-2013, 05:37 AM   #13
Celtic Yokel
Member
 
Registered: Feb 2013
Location: Knighton, Powys, Mid Wales
Distribution: Linux Mint
Posts: 41

Original Poster
Rep: Reputation: Disabled
Good morning, everyone. It's Tuesday and a glorious morning here.
Over the w/e I studied the advice from last week, and tried the suggestions - to no avail. I'd had no touble installing 11.04LTS, so last evening tried it with the present disk set-up - no problem. Re-installed 12.04LTS (after trying the upgrade option which seemed to make no difference)this morning - and it won't boot! The status bar in the installment showed GRUB being installed to sdb. Any more suggestions to get it working, please?
 
Old 02-19-2013, 08:57 AM   #14
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
What does "won't boot" mean? Does it display any messages or errors?
Can you get in at runlevel 1 or use a installer / rescue CD to look at the /var/log log files?
And is there a particular reason for not choosing one of the options posted in post #6 and just getting it over with?

Last edited by unSpawn; 02-19-2013 at 08:58 AM. Reason: //More *is* more
 
Old 02-20-2013, 05:20 AM   #15
Celtic Yokel
Member
 
Registered: Feb 2013
Location: Knighton, Powys, Mid Wales
Distribution: Linux Mint
Posts: 41

Original Poster
Rep: Reputation: Disabled
Good morning, unSpawn
The boot screen showed 'grub rescue', and doesn't go to a menu. None of the instructions I put in get me any further (my fault, I don't doubt, but, in spite of your advice which seemed clear enough on paper, I can't seem to get to where I need to be to sort it out). Probably it's down to a lack of knowledge on my part - for instance, quoting part of post 6 -
"If you installed Ubuntu on the second disk with the first disk attached then having it install its own bootloader code in the partition where Ubuntu is installed would keep you from having to mess with windows not booting. Then you would set up EasyBCD in windows to give you the choice to boot between windows and Linux."
I don't know how/where to find the bootloader code. I have actually downloaded EasyBCD, but have had to come back to download the appropriate .NET Framework for it, before I can install it.
What is runlevel 1?
I really appreciate the time you're spending on this; it's a pity I'm such a numpty!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
-bash: syntax error near unexpected token `(' akshaykb1 Linux - Newbie 3 11-21-2011 06:45 PM
[SOLVED] bash: syntax error near unexpected token `(' rc5gd Programming 6 07-13-2010 08:54 PM
[SOLVED] bash: syntax error near unexpected token `else' lucmove Programming 9 05-10-2010 09:03 PM
bash: syntax error near unexpected token `(' Folklore Linux - Newbie 1 05-02-2010 03:35 AM
-bash: syntax error near unexpected token ty1on Linux - Newbie 3 08-26-2009 02:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration