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.

#!/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 "+---------------------------------------------------------------------------------+"

$("")

Regards,
Alister

1 Like

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=""