From Wikipedia, the free encyclopedia
Computing desk
< June 28 << May | June | Jul >> June 30 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


June 29 Information

BASH Scripting

Can anyone point out what's wrong with this bit of Bash script? I've been staring at it for a while now, and can't see the problem.

if [ "$type" == "d" ];
then
   echo DEV;
elif [ "$type" == "t" ];
   echo TEST;
else
   echo "ERROR: Invalid environment specified"
   echo "       First parameter must be d or t"
   exit 1;
fi

When I run it I get a syntax error on the "else" line, saying

syntax error near unexpected token `else'

Rojomoke ( talk) 12:07, 29 June 2012 (UTC) reply

Missing then after elif
if [ "$type" == "d" ]
then
   echo "DEV"
elif [ "$type" == "t" ]
then
   echo "TEST"
else
   echo "ERROR: Invalid environment specified"
   echo "       First parameter must be d or t"
   exit 1
fi
-- Finlay McWalter Talk 12:29, 29 June 2012 (UTC) reply
Incidentally you might find a case statement makes for more readable and maintainable code:
case "$type" in
"d") echo "DEV" ;;
"t") echo "TEST" ;;

*) echo "ERROR: Invalid environment specified"
   echo "       First parameter must be d or t"
   exit 1
   ;;

esac
-- Finlay McWalter Talk 12:33, 29 June 2012 (UTC) reply
Many thanks for that! So you need a "then" after the "if" and the "elif", but not the "else"? Sheesh! Rojomoke ( talk) 13:09, 29 June 2012 (UTC) reply
Interesting (to me) is that I know nowt about Bash but would have guessed a missing "then". Don't forget that "elif" is still a kind of "if", so every one must have a matching "then", whereas "else" refers to whatever's left after the distinct conditions have been handled and no "then" is needed. 109.148.243.127 ( talk) 13:43, 29 June 2012 (UTC) reply
Mmm. Although I accept that BASH insists, to me both instances of
then
appear redundant. Were they not there, why could BASH not echo the strings (other than that it insists on thens)? In other words, why do the Ifs and Elseifs not work like the else? -- Tagishsimon (talk) 13:52, 29 June 2012 (UTC) reply
...Because "if" and "elif" use a conditional clause, whose length is a priori unknown to the shell interpreter. Requiring the "then" keyword to terminate and delimit the conditional phrase makes it easier to implement the shell interpreter, at the expense of " syntactic sugar" redundancy in the bash scripting language. Source code for the most common implementation of bash is availalbe: GNU BASH, from the FSF. If you have a lot of time, you can inspect the code that handles conditional tokenization. Without even looking, I can tell you "it's horrible." Nimur ( talk) 15:39, 29 June 2012 (UTC) reply
There's actually no redundancy. It's a little-used feature, but you can have multiple statements between the "if" and the "then". The last one is the one whose exit value is used to determine flow. Try these two examples, differing only in the placement of the "then":
if false
   true
then
   echo hello
fi

if false
then
   true
   echo goodbye
fi
The same idea applies to while loops (multiple statements between "while" and "do"), where it is more likely to be useful, because the "extra" statements are executed for every loop iteration.
98.226.12.79 ( talk) 10:12, 30 June 2012 (UTC) reply

How to put an internet-shortcut from Internet Explorer into a local windows7 folder ?

I use 64 bit Internet Explorer v9.0.8 and Windows 7 Ultimate (64bit).
When I drag or right-click-drag the (tiny) web site favicon, located at the left of the http address in the address bar in Internet explorer, and drop it into the harddisk folder where I want to keep the link, then The link gets created as I want it to, but IT allways ALSO immediately GETS OPENED in a new Internet Explorer window, which is quite annoying.
How do I create the link without the "auto open" when I do it? -- 89.9.199.35 ( talk) 14:42, 29 June 2012 (UTC) reply

It's because pinned sites ALWAYS open in 32-bit Internet Explorer (so it has to load that up instead of the existing 64-bit browser) and to the best of my knowledge you can't change this. I appreciate that I don't know your exact circumstances, but the 64-bit browser is only there for people who specifically need it (basically insanely big webpages) and you'd probably be better off just using the 32-bit browser. The 32-bit browser is just as stable and offers a much wider range of plugins.  ZX81  talk 15:43, 29 June 2012 (UTC) reply
Yes, it's a bit strange (the 64bit-Windows prefering 32-bit Internet Explorer) Thanks for mentioning it!
But the same problem occurs in 32-bit Internet Explorer!
I do not need to open any DUPLICATE browser window at all! (of the currently open web page that I am creating a link for).
When dragging the link from a web page currently open in (32 or 64bit) Internet Explorer 9.0.8, the mouse pointer bubble help initially says: "Drag to taskbar to pin site", and when dragging and holding it over a folder then the bubble help text changes to: "Create link in <FolderName>", so this clearly is the intended function.
But why does the automatic immediate reopening happen? and how do I stop it? -- (OP) 89.9.193.10 ( talk) 19:29, 29 June 2012 (UTC) reply

colour requirements

I'm not sure, but I think this is the right place. For a project I'm working on, I need to provide drawings done in a Pantone colour scheme, complete with the PMS swatch# of each colour used, how do I do this, and find this information, preferably without having to buy an expensive drawing program?

85.210.118.241 ( talk) 17:06, 29 June 2012 (UTC) reply

If you want to do it in accordance with Pantone's requirements, you will need to pay. Pantone colours are not available for free. (Well, they might be, but I'm not going to tell you where) You might, however, find this plugin (the bottom one) for GIMP to be 'good enough'. - Cucumber Mike ( talk) 17:25, 29 June 2012 (UTC) reply
Which is hopefully based off http://www.pantone.com/pages/pantone/colorfinder.aspx values. ¦ Reisio ( talk) 23:43, 29 June 2012 (UTC) reply

name for wireless repeater

I installed a wireless repeater for a home network. When setting it up, it asked for a name and a password. I thought it might mess things up if I gave it the same name as the existing network so I gave it a different name. Can the repeater network have the same name as the regular wireless network? Bubba73 You talkin' to me? 17:16, 29 June 2012 (UTC) reply

It may be ok, but I wouldn't do it to my sys. It may break something that could be hard to revert. I found it safe to name my hard drive 'Active Virus Storage' though. This may cause hackers to think twice before accessing it.-- Canoe1967 ( talk) 17:18, 2 July 2012 (UTC) reply
Resolved

OK, I'll leave it as it is (a variation on the real network's name. Bubba73 You talkin' to me? 03:15, 5 July 2012 (UTC) reply

unmatched ) in regex

Hi, I have a fairly simple bit of Perl code that I've been adding to and which has been working mostly well. After a few more additions, I got an error: Unmatched ) in regex; marked by <-- HERE. HERE is pointing to a ) near the end of 'if ($file->{title} =~ /^File\:( ' (with lots of files specified inbetween, each separated by |). I don't know much about coding (in Perl) and I've made sure that any non-alphanumeric characters in the file names have / in front of them. I've searched google for help and there's plenty of responses about regex and /Q and /E or some such, but it means nothing to me. Can I have in simple language what I am meant to do to fix this? Thanks! Significand ( talk) 17:54, 29 June 2012 (UTC) reply

Nevermind, I found a stray ). Took so long to spot that. Significand ( talk) 21:20, 29 June 2012 (UTC) reply

Anatomy of BorderStyle

Does anyone know (or know where to find) how a .NET 3D control border is made up? Specifically, I need to know what system colours make up the border of a text box when its BorderStyle property is set to Fixed3D. I'm sure that it's a combination of System.Drawing.ButtonShadow, ControlLight, etc, but I can't work out exactly what colours are used, or what order they appear in at the various edges of the control. Thanks in advance for any help you can give. Tevildo ( talk) 18:10, 29 June 2012 (UTC) reply

From Wikipedia, the free encyclopedia
Computing desk
< June 28 << May | June | Jul >> June 30 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


June 29 Information

BASH Scripting

Can anyone point out what's wrong with this bit of Bash script? I've been staring at it for a while now, and can't see the problem.

if [ "$type" == "d" ];
then
   echo DEV;
elif [ "$type" == "t" ];
   echo TEST;
else
   echo "ERROR: Invalid environment specified"
   echo "       First parameter must be d or t"
   exit 1;
fi

When I run it I get a syntax error on the "else" line, saying

syntax error near unexpected token `else'

Rojomoke ( talk) 12:07, 29 June 2012 (UTC) reply

Missing then after elif
if [ "$type" == "d" ]
then
   echo "DEV"
elif [ "$type" == "t" ]
then
   echo "TEST"
else
   echo "ERROR: Invalid environment specified"
   echo "       First parameter must be d or t"
   exit 1
fi
-- Finlay McWalter Talk 12:29, 29 June 2012 (UTC) reply
Incidentally you might find a case statement makes for more readable and maintainable code:
case "$type" in
"d") echo "DEV" ;;
"t") echo "TEST" ;;

*) echo "ERROR: Invalid environment specified"
   echo "       First parameter must be d or t"
   exit 1
   ;;

esac
-- Finlay McWalter Talk 12:33, 29 June 2012 (UTC) reply
Many thanks for that! So you need a "then" after the "if" and the "elif", but not the "else"? Sheesh! Rojomoke ( talk) 13:09, 29 June 2012 (UTC) reply
Interesting (to me) is that I know nowt about Bash but would have guessed a missing "then". Don't forget that "elif" is still a kind of "if", so every one must have a matching "then", whereas "else" refers to whatever's left after the distinct conditions have been handled and no "then" is needed. 109.148.243.127 ( talk) 13:43, 29 June 2012 (UTC) reply
Mmm. Although I accept that BASH insists, to me both instances of
then
appear redundant. Were they not there, why could BASH not echo the strings (other than that it insists on thens)? In other words, why do the Ifs and Elseifs not work like the else? -- Tagishsimon (talk) 13:52, 29 June 2012 (UTC) reply
...Because "if" and "elif" use a conditional clause, whose length is a priori unknown to the shell interpreter. Requiring the "then" keyword to terminate and delimit the conditional phrase makes it easier to implement the shell interpreter, at the expense of " syntactic sugar" redundancy in the bash scripting language. Source code for the most common implementation of bash is availalbe: GNU BASH, from the FSF. If you have a lot of time, you can inspect the code that handles conditional tokenization. Without even looking, I can tell you "it's horrible." Nimur ( talk) 15:39, 29 June 2012 (UTC) reply
There's actually no redundancy. It's a little-used feature, but you can have multiple statements between the "if" and the "then". The last one is the one whose exit value is used to determine flow. Try these two examples, differing only in the placement of the "then":
if false
   true
then
   echo hello
fi

if false
then
   true
   echo goodbye
fi
The same idea applies to while loops (multiple statements between "while" and "do"), where it is more likely to be useful, because the "extra" statements are executed for every loop iteration.
98.226.12.79 ( talk) 10:12, 30 June 2012 (UTC) reply

How to put an internet-shortcut from Internet Explorer into a local windows7 folder ?

I use 64 bit Internet Explorer v9.0.8 and Windows 7 Ultimate (64bit).
When I drag or right-click-drag the (tiny) web site favicon, located at the left of the http address in the address bar in Internet explorer, and drop it into the harddisk folder where I want to keep the link, then The link gets created as I want it to, but IT allways ALSO immediately GETS OPENED in a new Internet Explorer window, which is quite annoying.
How do I create the link without the "auto open" when I do it? -- 89.9.199.35 ( talk) 14:42, 29 June 2012 (UTC) reply

It's because pinned sites ALWAYS open in 32-bit Internet Explorer (so it has to load that up instead of the existing 64-bit browser) and to the best of my knowledge you can't change this. I appreciate that I don't know your exact circumstances, but the 64-bit browser is only there for people who specifically need it (basically insanely big webpages) and you'd probably be better off just using the 32-bit browser. The 32-bit browser is just as stable and offers a much wider range of plugins.  ZX81  talk 15:43, 29 June 2012 (UTC) reply
Yes, it's a bit strange (the 64bit-Windows prefering 32-bit Internet Explorer) Thanks for mentioning it!
But the same problem occurs in 32-bit Internet Explorer!
I do not need to open any DUPLICATE browser window at all! (of the currently open web page that I am creating a link for).
When dragging the link from a web page currently open in (32 or 64bit) Internet Explorer 9.0.8, the mouse pointer bubble help initially says: "Drag to taskbar to pin site", and when dragging and holding it over a folder then the bubble help text changes to: "Create link in <FolderName>", so this clearly is the intended function.
But why does the automatic immediate reopening happen? and how do I stop it? -- (OP) 89.9.193.10 ( talk) 19:29, 29 June 2012 (UTC) reply

colour requirements

I'm not sure, but I think this is the right place. For a project I'm working on, I need to provide drawings done in a Pantone colour scheme, complete with the PMS swatch# of each colour used, how do I do this, and find this information, preferably without having to buy an expensive drawing program?

85.210.118.241 ( talk) 17:06, 29 June 2012 (UTC) reply

If you want to do it in accordance with Pantone's requirements, you will need to pay. Pantone colours are not available for free. (Well, they might be, but I'm not going to tell you where) You might, however, find this plugin (the bottom one) for GIMP to be 'good enough'. - Cucumber Mike ( talk) 17:25, 29 June 2012 (UTC) reply
Which is hopefully based off http://www.pantone.com/pages/pantone/colorfinder.aspx values. ¦ Reisio ( talk) 23:43, 29 June 2012 (UTC) reply

name for wireless repeater

I installed a wireless repeater for a home network. When setting it up, it asked for a name and a password. I thought it might mess things up if I gave it the same name as the existing network so I gave it a different name. Can the repeater network have the same name as the regular wireless network? Bubba73 You talkin' to me? 17:16, 29 June 2012 (UTC) reply

It may be ok, but I wouldn't do it to my sys. It may break something that could be hard to revert. I found it safe to name my hard drive 'Active Virus Storage' though. This may cause hackers to think twice before accessing it.-- Canoe1967 ( talk) 17:18, 2 July 2012 (UTC) reply
Resolved

OK, I'll leave it as it is (a variation on the real network's name. Bubba73 You talkin' to me? 03:15, 5 July 2012 (UTC) reply

unmatched ) in regex

Hi, I have a fairly simple bit of Perl code that I've been adding to and which has been working mostly well. After a few more additions, I got an error: Unmatched ) in regex; marked by <-- HERE. HERE is pointing to a ) near the end of 'if ($file->{title} =~ /^File\:( ' (with lots of files specified inbetween, each separated by |). I don't know much about coding (in Perl) and I've made sure that any non-alphanumeric characters in the file names have / in front of them. I've searched google for help and there's plenty of responses about regex and /Q and /E or some such, but it means nothing to me. Can I have in simple language what I am meant to do to fix this? Thanks! Significand ( talk) 17:54, 29 June 2012 (UTC) reply

Nevermind, I found a stray ). Took so long to spot that. Significand ( talk) 21:20, 29 June 2012 (UTC) reply

Anatomy of BorderStyle

Does anyone know (or know where to find) how a .NET 3D control border is made up? Specifically, I need to know what system colours make up the border of a text box when its BorderStyle property is set to Fixed3D. I'm sure that it's a combination of System.Drawing.ButtonShadow, ControlLight, etc, but I can't work out exactly what colours are used, or what order they appear in at the various edges of the control. Thanks in advance for any help you can give. Tevildo ( talk) 18:10, 29 June 2012 (UTC) reply


Videos

Youtube | Vimeo | Bing

Websites

Google | Yahoo | Bing

Encyclopedia

Google | Yahoo | Bing

Facebook