Sponsored Content
Top Forums Shell Programming and Scripting There's a unknown command on line 1 and i don't know whats causing it. Post 302839211 by thatguy565 on Wednesday 31st of July 2013 06:13:45 PM
Old 07-31-2013
There's a unknown command on line 1 and i don't know whats causing it.

My OS is Linux GL version 2.4.26. I am trying to make a shell script that outputs a chart displaying info of who is online, boot time, and the real time, I have manage to get it to work, but I still get the error "./user/script: line 1: : command not found." I do in fact have access to root, if that makes any difference. Although i do expect this to be either something i did wrong but just don't understand, or a bug in the Linux system.

Code:
#!/bin/bash

# it looks ugly without a clear... sooooo

clear

# This section is the time determining section

# the time command

tme=$(date);

# This is the system boot time determining section

# command for looking at boot time

boot=$(who -b);

# This section is the Users online determining section


# setting w and its arguments

wr=$(w -h root);
wg=$(w -h glucero565);
wa=$(w -h alucero565);

# determining weither or not root is logged in

if [ "$wr" != "" ]
	then
		line1=$(w -h root);
	else
		line1=$("");
fi

# determining weither or not glucero565 is logged in

if [ "$wg" != "" ]
	then
		line2=$(w -h glucero565);
	else
		line2=$("");
fi

# determining weither or not alucero565 is loggin in

if [ "$wa" != "" ]
	then
		line3=$(w -h alucero565);
	else
		line3=$("");
fi

# inserting parts of the chart

echo "                                   Info                                            "
echo "+---------------------------------------------------------------------------------+"
echo "|                                                                                 |"

# inserting current time here

echo "|                           $tme                          |"

# inserting boot time here

echo "|                  $boot                             |"

# determining what to put in the first line of the User section of the chart

if [ "$line1" == "" ]
	then
		echo "|                                                                                 |"
	else
		echo "| $line1 |"
fi

# determining what to put in the second line of the chart

if [ "$line2" == "" ]
	then
		echo "|                                                                                 |"
	else
		echo "| $line2 |"
fi

# determining what to put in the third line of the chart

if [ "$line3" == "" ]
	then
		echo "|                                                                                 |"
	else
		echo "| $line3 |"
fi

# inserting parts of the chart

echo "|                                                                                 |"
echo "+---------------------------------------------------------------------------------+"

 

10 More Discussions You Might Find Interesting

1. Solaris

Whats the command to see

What fonts are installed on a Solaris 8? I have no GUI so a command line command would be great. Thank you (2 Replies)
Discussion started by: Acleoma
2 Replies

2. UNIX for Dummies Questions & Answers

Variable for -name causing issue in Find command

Hi there, I'm trying to find files that are greater then 30 days old, zip them and move to a different directory. I'm encountering an issue passing a variable (FilesToFind) to name within the find command. Here's the code I'm running: #! /usr/bin/sh FileDir=/home/ariba... (2 Replies)
Discussion started by: ParNone
2 Replies

3. Shell Programming and Scripting

Whats wrong with this 5 line script!

Hi #!/bin/sh user=$1 if " -eq 0 ] echo "No" else echo "Yes" fi I'm not quite sure whats wrong with this but I know its something silly. Any ideas? Thanks (9 Replies)
Discussion started by: c19h28O2
9 Replies

4. Shell Programming and Scripting

Get the line number of an unknown line

I need to get the line number for a line, but I don't know where the file the line will appear. The line is always constant, but appears in different places. ie abc bcd cde fff aaa bbb ccc ddd and I would need the line number for fff, any help on this would be greatly appreciated. (2 Replies)
Discussion started by: hidachab
2 Replies

5. Shell Programming and Scripting

Whats wrong with this line?

I have a file $I_FILE that I need to filter and store the 1st and the 9th columns in another file $O_FILE. With this in Perl, system ("awk -F, '{print \$1, \$9}' \$I_FILE | sed '\/^\$\/d' > O_FILE"); I get: 4096045055 The first line in I_FILE is:... (5 Replies)
Discussion started by: looza
5 Replies

6. Shell Programming and Scripting

whats wrong with this line using perl

E:\>perl -00ne 'push @a,"$_\0$ARGV\n";END{print reverse split/\0/ for sort @a}' file1-obj_prof.out.txt file2-obj_prof.out.txt' Can't find string terminator "'" anywhere before EOF at -e line 1. (6 Replies)
Discussion started by: richsark
6 Replies

7. Shell Programming and Scripting

Whats does this export command do?

Hi, I know that export command is used to set environment variable. Can you please explain what ":--100" in the below command is doing? export ROWSTOLOAD=${ROWSTOLOAD:--100} Thanks, Gangadhar (5 Replies)
Discussion started by: Gangadhar Reddy
5 Replies

8. Shell Programming and Scripting

Pipe causing last command error to not function

Hi I am quite new to scripting and cannot work out how to do the following - I want to pipe to a log file and then use the "last statement error" in an if statement after, and this doesn't work because it checks the pipe statement instead of the script. Example: executteTheScript $var |... (4 Replies)
Discussion started by: erjorgito
4 Replies

9. Shell Programming and Scripting

While loop is causing ssh command to exit from script after first iteration.

I am trying to check multiple server's "uptime" in a loop over "ssh". When I execute multiple ssh commands with hard coded servernames script is executing fine. But when I pass server names using while loop, script is exiting after checking first server's status, why? # serverList... (8 Replies)
Discussion started by: kchinnam
8 Replies

10. Programming

Arduino-cli - Uploading to Unknown Chinese Arduino Boards using the Arduino Command Line Interface

In my further exploration of Arduino, today I decided to install the arduino-cli on my mac today. https://github.com/arduino/arduino-cli I followed the instructions for macOS but when I got to this part: arduino-cli board list I got the dreaded "Unknown" Fully Qualified Board Name... (1 Reply)
Discussion started by: Neo
1 Replies
SCRIPT(1)						    BSD General Commands Manual 						 SCRIPT(1)

NAME
script -- make typescript of terminal session SYNOPSIS
script [-akq] [-t time] [file [command ...]] DESCRIPTION
The script utility makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. If the argument command is given, script will run the specified command with an optional argument vector instead of an interactive shell. The following options are available: -a Append the output to file or typescript, retaining the prior contents. -k Log keys sent to program as well as output. -q Run in quiet mode, omit the start and stop status messages. -t time Specify time interval between flushing script output file. A value of 0 causes script to flush for every character I/O event. The default interval is 30 seconds. The script ends when the forked shell (or command) exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-D (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the typescript file. The script utility works best with commands that do not manipulate the screen. The results are meant to emulate a hardcopy terminal, not an addressable one. ENVIRONMENT
The following environment variable is utilized by script: SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically). SEE ALSO
csh(1) (for the history mechanism). HISTORY
The script command appeared in 3.0BSD. BUGS
The script utility places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects. It is not possible to specify a command without also naming the script file because of argument parsing compatibility issues. When running in -k mode, echo cancelling is far from ideal. The slave terminal mode is checked for ECHO mode to check when to avoid manual echo logging. This does not work when in a raw mode where the program being run is doing manual echo. BSD
January 22, 2004 BSD
All times are GMT -4. The time now is 12:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy