Skip to main content
added 137 characters in body
Source Link
James
  • 13
  • 4

I want to use an argument in the function I created in my .profile file.

I want to ask for input if no argument is given, otherwise set a variable to $1.

When I check $1 to see if it is empty, I get the following error:

sh[7]: 1: Parameter not set.

From the following line:

if [ ! -n "$1" ]; then

I'm using sh not bash.

EDIT: Ok, here is the wholefirst line of code until the end of the if statmentstatement:

HOST=`hostname`
cd /opt/dirpath
ll *.sto


if [ !x"$1" -n= "$1"x ]; then
  # Ask for input
  echo "File: \c"; read outFile
else
    outFile=$1
fi

I'm editing someone else's code to work with or without arguments.

I want to use an argument in the function I created in my .profile file.

I want to ask for input if no argument is given, otherwise set a variable to $1.

When I check $1 to see if it is empty, I get the following error:

sh[7]: 1: Parameter not set.

From the following line:

if [ ! -n "$1" ]; then

I'm using sh not bash.

EDIT: Ok, here is the whole if statment:

if [ ! -n "$1" ]; then
  # Ask for input
  echo "File: \c"; read outFile
else
    outFile=$1
fi

I'm editing someone else's code to work with or without arguments.

I want to use an argument in the function I created in my .profile file.

I want to ask for input if no argument is given, otherwise set a variable to $1.

When I check $1 to see if it is empty, I get the following error:

sh[7]: 1: Parameter not set.

From the following line:

if [ ! -n "$1" ]; then

I'm using sh not bash.

EDIT: Ok, here is the first line of code until the end of the if statement:

HOST=`hostname`
cd /opt/dirpath
ll *.sto


if [ x"$1" = x ]; then
  # Ask for input
  echo "File: \c"; read outFile
else
    outFile=$1
fi

I'm editing someone else's code to work with or without arguments.

added 219 characters in body
Source Link
James
  • 13
  • 4

I want to use an argument in the function I created in my .profile file.

I want to ask for input if no argument is given, otherwise set a variable to $1.

When I check $1 to see if it is empty, I get the following error:

sh[7]: 1: Parameter not set.

From the following line:

if [ ! -n "$1" ]; then

I'm using sh not bash.

EDIT: Ok, here is the whole if statment:

if [ ! -n "$1" ]; then
  # Ask for input
  echo "File: \c"; read outFile
else
    outFile=$1
fi

I'm editing someone else's code to work with or without arguments.

I want to use an argument in the function I created in my .profile file.

I want to ask for input if no argument is given, otherwise set a variable to $1.

When I check $1 to see if it is empty, I get the following error:

sh[7]: 1: Parameter not set.

From the following line:

if [ ! -n "$1" ]; then

I'm using sh not bash.

I want to use an argument in the function I created in my .profile file.

I want to ask for input if no argument is given, otherwise set a variable to $1.

When I check $1 to see if it is empty, I get the following error:

sh[7]: 1: Parameter not set.

From the following line:

if [ ! -n "$1" ]; then

I'm using sh not bash.

EDIT: Ok, here is the whole if statment:

if [ ! -n "$1" ]; then
  # Ask for input
  echo "File: \c"; read outFile
else
    outFile=$1
fi

I'm editing someone else's code to work with or without arguments.

deleted 2 characters in body
Source Link
James
  • 13
  • 4

I want to use an argument in the function I created in my .profile file.

I want to ask for input if no argument is given, otherwise set a variable to $1.

When I check $1 to see if it is empty, I get the following error:

sh[7]: 1: Parameter not set.

From the following line:

if [[[ ! -n "$1" ]];]; then

I'm using sh not bash.

I want to use an argument in the function I created in my .profile file.

I want to ask for input if no argument is given, otherwise set a variable to $1.

When I check $1 to see if it is empty, I get the following error:

sh[7]: 1: Parameter not set.

From the following line:

if [[ ! -n "$1" ]]; then

I'm using sh not bash.

I want to use an argument in the function I created in my .profile file.

I want to ask for input if no argument is given, otherwise set a variable to $1.

When I check $1 to see if it is empty, I get the following error:

sh[7]: 1: Parameter not set.

From the following line:

if [ ! -n "$1" ]; then

I'm using sh not bash.

Source Link
James
  • 13
  • 4
Loading