0

Hey guys, Im in a basic programming class. Mainly using VBS scripting nothing else on Windows XP. All of the sudden my prof gave us this assignment for shell scripting. I don't know hardly anything about this.

Objective: Create a single shell script in Windows/Linux that will do (all) the following:

1.Create a text file that lists the operating system of your computer, the computer's name and user name. The OS, computer name and user name can be obtained via the appropriate environment variables. The redirection operators will needed to be used to create the text file.
2. Append to the text file a listing of the files and folders in the current directory. Use the dir/ls command and redirection operators.
3. Create a variable called myName and assign your last name to this variable. Use the set/set command.
4. Create a directory that uses the value of the myName variable as the directory name. Use the md/mkdir command.
5. Copy the report text file into the newly-created directory. Use the copy/cp command.

Now this is my assignment, I don't want any one to do this for me, I just need help on figuring out how to do it. For instance in number 1 what is the 'appropriate environment variables' also I don't know the appropriate syntax for shell scripting. But I have been searching everywhere and what I have got so far is:
@Echo off

echo Operating system: %OS% > report.txt
echo Computer name: %COMPUTERNAME>> report.txt
echo User name: %USERNAME% >> report.txt

If I understand the problem correctly it doesn't want it in a Report.txt but instead to display in the CLI. Am I starting off right here or no??

Thanks guys for any help. sorry if any of this is confusing to you cause it is to me. I am a networking guy don't do a whole lot with scripts.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by cfajohnson
0

Hey guys, Im in a basic programming class. Mainly using VBS scripting nothing else on Windows XP. All of the sudden my prof gave us this assignment for shell scripting. I don't know hardly anything about this.

Objective: Create a single shell script in Windows/Linux that will do (all) the following:

1.Create a text file that lists the operating system of your computer, the computer's name and user name. The OS, computer name and user name can be obtained via the appropriate environment variables. The redirection operators will needed to be used to create the text file.
2. Append to the text file a listing of the files and folders in the current directory. Use the dir/ls command and redirection operators.
3. Create a variable called myName and assign your last name to this variable. Use the set/set command.

The Unix shell does not use set to assign values to variables.

  1. Create a directory that uses the value of the myName variable as the directory name. Use the md/mkdir command.
  2. Copy the report text file into the newly-created directory. Use the copy/cp command.

Now this is my assignment, I don't want any one to do this for me, I just need help on figuring out how to do it. For instance in number 1 what is the 'appropriate environment variables' also I don't know the appropriate syntax for shell scripting. But I have been searching everywhere and what I have got so far is:

Please put code inside code-tags as I have done below.

@Echo off

That is not a valid command in a Unix shell script.

It's also not necessary, as commands to be executed in a script are not displayed by default.

echo Operating system: %OS% > report.txt

In the Unix shell, variable references are preceded by a dollar sign, not enclosed in percent signs.

echo Computer name: %COMPUTERNAME>> report.txt
echo User name: %USERNAME% >> report.txt

If I understand the problem correctly it doesn't want it in a Report.txt but instead to display in the CLI. Am I starting off right here or no??

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.