Sponsored Content
Full Discussion: Stuck after typing goto
Top Forums UNIX for Dummies Questions & Answers Stuck after typing goto Post 302136930 by Perderabo on Thursday 20th of September 2007 01:19:04 PM
Old 09-20-2007
Wow! I have never encountered this before! Yet another reason to avoid csh. You must be using csh or tcsh as your shell. If you would switch to bash, you would not have this problem. But when csh sees an input line like "goto fubar", it will actually skip all further input lines until it encounters a line labeled "fubar". You can supply such an input line the first time. After that, another "goto fubar" sends it back to where it encountered the line labeled "fubar". Nice design...not.

Code:
$ csh
%echo $shell
/bin/tcsh
%goto fubar
goto? hello
goto? echo $shell
goto? fubar:
%date ; sleep 2
Thu Sep 20 13:06:49 EDT 2007
%
%
%
%echo we are gonna loop
we are gonna loop
%goto fubar
Thu Sep 20 13:07:16 EDT 2007
we are gonna loop
Thu Sep 20 13:07:18 EDT 2007
we are gonna loop
Thu Sep 20 13:07:20 EDT 2007
we are gonna loop
Thu Sep 20 13:07:22 EDT 2007
we are gonna loop
Thu Sep 20 13:07:24 EDT 2007
we are gonna loop
Thu Sep 20 13:07:26 EDT 2007
we are gonna loop

I'm guessing that the "fubar:" line needs to be in the history list in order to loop, but I don't feel like testing that.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to goto in ksh

Hi, I'm trying to use the goto in ksh but it does not appear to be a valid command. Is that only valid in csh? Anything similar in ksh that I can use? Appreciate any help you can provide. Thanks. geraldine (4 Replies)
Discussion started by: Geraldine
4 Replies

2. Shell Programming and Scripting

Use of GOTO statement in scripts

Hey Guys.. I just want to know how to use Goto statement in shell scripts. I know the basic use of statement. Goto Label The above statement will search for some label which must be defined in the script itself as: label: I tried these combinations but I didn't work out for me and I'm... (7 Replies)
Discussion started by: vikasduhan
7 Replies

3. Shell Programming and Scripting

goto statement

I have a test script for using goto statement but its not working. please help i tried both in linux and hp-ux it's not working please help #! /bin/ksh t=`ps -ef|grep ti.sh|grep -v grep` if ; then goto start else goto stop fi start: echo "start" stop: echo "stop" (5 Replies)
Discussion started by: Krrishv
5 Replies

4. Solaris

Goto last visted directory

Dear All, Can any one pls let me the command for how to goback to previous visited directory from the current working directory in SunOS ? In case of HP-UX; the same can be resolved through "cd -" command. Thanks in advance! Prasanth Babu. (6 Replies)
Discussion started by: prasanth_babu
6 Replies

5. Shell Programming and Scripting

No output to CL when typing in CL.

Hello all, I am in a terminal on Solaris and something weird is happening... When I am typing I can't see what I am typing, although what I am typing is working. As is if I type the command and hit enter, the command runs. Anyone have a clue why or how I can make it display my typing? Is... (2 Replies)
Discussion started by: komputersman
2 Replies

6. Shell Programming and Scripting

Using A Goto Label?

Im trying to do something like this but I cant find any documentation. read X if then goto ThisLine fi OTHER CODE OTHER CODE Label: ThisLine echo "You entered 1" (5 Replies)
Discussion started by: Grizzly
5 Replies

7. UNIX for Dummies Questions & Answers

No $ when typing cw

Hi As a dummy my question is very simple. When typing cw I've read (many times) that a '$' should appear at the end of the word I'm about to change. However, it doesn't, and in my case the word is instantly deleted and so ready to be changed! Can somebody tell me why this is, or maybe I... (4 Replies)
Discussion started by: joesh
4 Replies

8. Shell Programming and Scripting

Zero typing problem!

H, I I have this below script for removing the full path from a string which is indeed a filepath location if windows. It converts input \abc\asssh\abc To abc But if filename has 0 like: \abc\abc\00000Hgg Then its typing abc00000Hgg PLEASE note that its solaris. Script is: more... (10 Replies)
Discussion started by: nixhead
10 Replies

9. Shell Programming and Scripting

Alternative for goto

#!/bin/sh label: echo sql poll v=`sqlplus -s <<! HR/HR set pages 0 echo off feed off select distinct status from emp where id=5; ! ` echo $v; echo it comes here after false if then echo if condition true sqlplus -l scott/tiger <<EOF select * from department; EXIT (2 Replies)
Discussion started by: kumaar1986
2 Replies

10. Shell Programming and Scripting

A dash to GOTO or a dash from GOTO, that is the question...

Well, guys I saw a question about GOTO for Python. So this gave me the inspiration to attempt a GOTO function for 'dash', (bash and ksh too). Machine: MBP OSX 10.14.3, default bash terminal, calling '#!/usr/local/bin/dash'... This is purely a fun project to see if it is possible in PURE... (3 Replies)
Discussion started by: wisecracker
3 Replies
getdate(3C)															       getdate(3C)

NAME
getdate() - convert user format date and time SYNOPSIS
Obsolescent Interface DESCRIPTION
The function converts user definable date and/or time specifications pointed to by string into a The structure declaration is in the header file (see ctime(3C)). User-supplied templates are used to parse and interpret the input string. The templates are text files created by the user and identified via the environment variable should be set to indicate the full path name of the template file. The first line in the template that matches the input specification is used for interpretation and conversion into the internal time format. Upon successful completion, returns a pointer to a otherwise, it returns NULL and the symbol is set to indicate the error. The following field descriptors are supported: same as abbreviated weekday name full weekday name abbreviated month name full month name locale's appropriate date and time representation century number (00 through 99; leading zeros are permitted but not required) day of the month (01 through 31; the leading 0 is optional) same as date as abbreviated month name hour (00 through 23) hour (01 through 12) month number (01 through 12) minute (00 through 59) same as locale's equivalent of either AM or PM time as time as seconds (00 through 61) insert a tab time as weekday number (Sunday = 0 through Saturday = 6) locale's appropriate date representation locale's appropriate time representation year without century (00 through 99). For inputs 69-99, the 20th century(1900s) is assumed, and for inputs 00-68, the 21st century(2000s) is assumed. year as ccyy (e.g., 1986) time zone name or no characters if no time zone exists. If the time zone supplied by is not the same as the time zone expects, an invalid specification error is returned. calcu- lates the expected time zone from the environment variable. Month and weekday names may consist of any combination of uppercase and lowercase letters. The user can request that the input date or time specification be in a specific language by setting the category (see setlocale(3C)). For descriptors that allow leading zeros, leading zeros are optional. However, the number of digits used for those descriptors must not exceed two, including leading zeros. Extra whitespace in either the template file or in string is ignored. The field descriptors and are not supported if they include unsupported field descriptors. The following example shows the possible contents of a template: The following are examples of valid input specifications for the above template: If the category is set to a German locale that includes as a weekday name and as a month name, the following would be valid: This example shows how local date and time specification can be defined in the template: +---------------------------+------------------+ | Invocation | Line in Template | +---------------------------+------------------+ |getdate("11/27/86") | %m/%d/%y | |getdate("27.11.86") | %d.%m.%y | |getdate("86-11-27") | %y-%m-%d | |getdate("Friday 12:00:00") | %A %H:%M:%S | +---------------------------+------------------+ The following rules apply when converting the input specification into the internal format: o If only the weekday is given, today is assumed if the given day is equal to the current day, and next week if it is less. o If only the month is given, the current month is assumed if the given month is equal to the current month, and next year if it is less and no year is given (the first day of the month is assumed if no day is given). o If no hour, minute and second are given, the current hour, minute and second are assumed. o If no date is given, today is assumed if the given hour is greater than the current hour and tomorrow is assumed if it is less. The following examples help to illustrate the above rules assuming that the current date is and the category is set to the default locale. +-------------+----------+------------------------------+ | | Line in | | | Input | Template | Date | +-------------+----------+------------------------------+ |Mon | %a | Mon Sep 22 12:19:47 EDT 1986 | |Sun | %a | Sun Sep 28 12:19:47 EDT 1986 | |Fri | %a | Fri Sep 26 12:19:47 EDT 1986 | |September | %B | Mon Sep 1 12:19:47 EDT 1986 | |January | %B | Thu Jan 1 12:19:47 EST 1987 | |December | %B | Mon Dec 1 12:19:47 EST 1986 | |Sep Mon | %b %a | Mon Sep 1 12:19:47 EDT 1986 | |Jan Fri | %b %a | Fri Jan 2 12:19:47 EST 1987 | |Dec Mon | %b %a | Mon Dec 1 12:19:47 EST 1986 | |Jan Wed 1989 | %b %a %Y | Wed Jan 4 12:19:47 EST 1989 | |Fri 9 | %a %H | Fri Sep 26 09:00:00 EDT 1986 | |Feb 10:30 | %b %H:%S | Sun Feb 1 10:30:00 EST 1987 | |10:30 | %H:%M | Tue Sep 23 10:30:00 EDT 1986 | |13:30 | %H:%M | Mon Sep 22 13:30:00 EDT 1986 | +-------------+----------+------------------------------+ Obsolescent Interface converts user format date and time. Also see the section. ERRORS
Upon failure, returns NULL and the symbol is set to indicate the error. The following is a complete list of the settings and their interpretation: the environment variable is null or undefined, the template file cannot be opened for reading, failed to get file status information, the template file is not a regular file, an error is encountered while reading the template file, memory allocation failed (not enough memory available), there is no line in the template that matches the input, invalid input specification. For example, February 31; or the time specified cannot be represented in the data type in 32-bit HP-UX (which represents Tuesday January 19 03:14:07 UTC, 2038) or exceeds the maximum date supported in 64-bit HP-UX (which is Friday December 31 23:59:59 UTC, 9999). WARNINGS
The return value for points to data whose content is overwritten by each call by the same thread. is an obsolescent interface supported only for compatibility with existing DCE applications. New multi-threaded applications should use SEE ALSO
ctime(3C), ctype(3C), setlocale(3C), strftime(3C), thread_safety(5). getdate(3C)
All times are GMT -4. The time now is 08:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy