There's a unknown command on line 1 and i don't know whats causing it.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting There's a unknown command on line 1 and i don't know whats causing it.
# 1  
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 "+---------------------------------------------------------------------------------+"

# 2  
Old 07-31-2013
Quote:
Originally Posted by thatguy565
"./user/script: line 1: : command not found."
$("")

Regards,
Alister
This User Gave Thanks to alister For This Post:
# 3  
Old 08-01-2013
line1=$("")
You try to set a variable using "" as a command.
Since "" is not a valid command, it will fail
If you just try to set it to blank, use:
line1=""
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question