Windows to Unix? Using bash


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Windows to Unix? Using bash
# 1  
Old 11-30-2010
Windows to Unix? Using bash

Im posting here as i posted this in the wrong section before, sorry about that.

Ok, im doing a self teaching course, im trying to understand how unix works, get and understand the basics before i hit the advance level.

Now i have this in windows, Btw im always new at windows so correct me if i have any mistakes known.

Code:
@echo off
echo.
echo SELECT OPTION
echo -------------
echo.
:menu
echo 1- Create username
echo 2- Create password
echo 3- Delete username
echo 4- Exit
echo.
pause
set /p option=enter option 1 2 3 or 4:
if %option%==1 goto createuser
if %option%==2 goto createpass
if %option%==3 goto deluser
if %option%==4 goto exit

:createuser
echo Enter username
set /p var=Username:
net user %var% /add
echo Username successfully entered
goto :end

:createpass
echo Enter password
net user %var% *
echo Password successfully entered
goto :end

:deluser
echo Enter user to be deleted
set first=%inputvar%
echo User deleted
goto :end
:exit

Whats the code for unix, is it similiar? Or completely different any help would be appreciated

If someone can do a code for create username on unix using bash it would be awesome, once i have an idea i can then try password n delete by myself before i ask for any more help.

Thank You

Last edited by newbie987; 12-07-2010 at 05:57 AM.. Reason: Please use code tags
# 2  
Old 11-30-2010
I suggest you begin with a tutorial.

BASH Programming - Introduction HOW-TO
This User Gave Thanks to droid For This Post:
# 3  
Old 11-30-2010
Just an example of how it can be done (first get rid of the GOTO):
bash code:
  1. #!/bin/bash
  2. while : ; do
  3.    echo "SELECT OPTION"
  4.    echo "-------------"
  5.    echo "1- Create username"
  6.    echo "2- Create password"
  7.    echo "3- Delete username"
  8.    echo "4- Exit"
  9.    read -p "enter option 1 2 3 or 4:" option
  10.    case option in
  11.       1) read -p "Enter username:"
  12.          adduser $REPLY && echo "Username successfully entered"   ;;
  13.       2) passwd && "Password successfully entered" ;;
  14.       3) read -p "Enter user to be deleted: "
  15.          deluser $REPLY && echo "User deleted"  ;;
  16.       4) exit  ;;
  17.       *) continue  ;;
  18.    esac
  19. done
This User Gave Thanks to frans For This Post:
# 4  
Old 11-30-2010
Thank You to both of you, i will give it a shot with the tutorial and thanks frans it does seem clearer, thats exactly what i needed, just an example, that helped me alot.

Thank You
# 5  
Old 12-05-2010
Ok i think i understand the codes now, but how do i delete multipler users as an admin.

So just say i have 4 user accounts, how can i delete multiple users?
# 6  
Old 12-05-2010
You could change part of your case statement:

bash code:
  1. 3) read -p "Enter users to be deleted: "  #whitespace-separated list of usernames to be deleted
  2.      for USER in $REPLY; do
  3.          deluser $USER && echo "User $USER deleted"  
  4.      done;;
# 7  
Old 12-05-2010
Ahem....

As of now all the posters seem to have silently assumed that you have a Linux system for your script.

There is no generalized "adduser" or "deluser" command in Unix. Unix is not an Operating System like "WinXP" or "MVS", but more a like an architecture blueprint. This blueprint is laid down in several standardizing documents (you might hear of "POSIX" - this is such a document). These documents generally state requirements: "a Unix system has to react so-and-so under these circumstances", "the system call syscall-x() has to return this and that under these circumstances and this-and-this under any other", etc..

Somebody could write an operating system obeying all these requirements and it would be a "Unix system". (Maybe you would be not allowed to call it that way because of trade mark issues, but lets disregard this aspect for the purpose of this discussion.)

Linux Torwalds, for instance, did this and created "Linux". Linux is in fact not a real Unix, there are intricate differences, but they aren't important for your purposes. IBM did the same and they created "AIX", which is a real Unix, Hewlett Packard also created their own Unix called "HP-ux", Sun Microsystems (now Oracle) created "SunOS/Solaris", etc.. The user administration is different (albeit similar) in all these versions of Unix.

This doesn't mean the solutions given to you are wrong or bad - not at all! It is just that they are not that universal as you might believe they are.

For this reason you will find that switching from one Unix system to any other is absolutely simple - for the user. It might be quite a difference for the administrator, because this is the part where Unixes differ most.

I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Windows Batch to Bash

This line is called in a windows batch file and I need to call the same 3 jars with Parms in a bash script. cd "D:\ACDRIP\JARS" java -cp ".\RIPError.jar;.\RIP31.jar;.\RIP31msg_en_US.jar" ResubmitErrors -Ahost -P185050 pause Any ideas how to do this in Bash? (3 Replies)
Discussion started by: xgringo
3 Replies

2. Shell Programming and Scripting

Windows Task with Bash script

Hello I have a problem with use bash script in windows task. If I use script by cygwin it's working well. If I use it by Windows task I'm get error Error : ERROR 2 (HY000) at line 2: File '.\xxx.csv' not found (Errcode: 2) Code Line : load data local infile './xxx.csv' REPLACE into... (16 Replies)
Discussion started by: karp
16 Replies

3. Shell Programming and Scripting

Needed SFTP script from windows to UNIX server and from UNIX to windows server(reverse SFTP)

hi guys, i need a script to sftp the file from windows to unix server ....(before that i have to check whether the file exists in the windows server or not and again i have to reverse sftp the files from unix to windows server..... regards, Vasa Saikumar. (13 Replies)
Discussion started by: hemanthsaikumar
13 Replies

4. Shell Programming and Scripting

Using BASH on windows

So I'm looking into using BASH on this windows 7 machine. I've installed cygwin with a few optional bash installations but I don't know how to get bash to "work". I've opened the .exe and typed what few commands I understand from the tutorials I've found but some of the commands do not work. I... (10 Replies)
Discussion started by: Cambria
10 Replies

5. Shell Programming and Scripting

Unix shell script to Copy files from one Windows server to another Windows server.

Can anybody please help me on how to code for the below requirement: I need to write a shell script (on different unix server) to copy files from multiple folders (ex. BRN-000001) from one windows server (\\boldls-mwe-dev4)to a different windows server(\\rrwin-ewhd04.ecomad.int). This shell... (4 Replies)
Discussion started by: SravsJaya
4 Replies

6. Shell Programming and Scripting

Batch job in unix server to move the pdf file from unix to windows.

Hi Experts, I have a requirement where i need to setup a batch job which runs everymonth and move the pdf files from unix server to windows servers. Could some body provide the inputs for this. and also please provide the inputs on how to map the network dirve in the unix like that... (1 Reply)
Discussion started by: ger199901
1 Replies

7. AIX

Do I need to configure my local windows to FTP files from local windows to a UNIX AIX server?

Hi Friends, I have this script for ftping files from AIX server to local windows xp. #!/bin/sh HOST='localsystem.net' USER='myid_onlocal' PASSWD='mypwd_onlocal' FILE='file.txt' ##This is a file on server(AIX) ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD put $FILE... (1 Reply)
Discussion started by: rajsharma
1 Replies

8. UNIX for Dummies Questions & Answers

Changing windows server alias name on windows or unix?

My situation is that we have production unix scripts that ftp files over to a windows server. I'm not sure if its a 2000 or 2003 server as I dont work on server, more on the unix side. It turns out that they are changing servers on the network. So they are migrating our data over from say Server 1... (1 Reply)
Discussion started by: NycUnxer
1 Replies

9. UNIX for Advanced & Expert Users

missing Path(in UNIX) when i launch a job on to unix machine using windows SSh

hi i want run an unix application from a windows program/application.i am using SSH(command line version)to log on to a unix machine from windows. the application has to read a configuration file inorder to run. the configuration file .CFG is in bin in my home directory. but the application... (1 Reply)
Discussion started by: megastar
1 Replies

10. UNIX for Dummies Questions & Answers

UNIX problem? Unix programm runs windows 2000 CPU over 100%

Okee problems...!! What is happening: Unix server with some programms, workstations are windows 2000, the workstations work good but when you start a programm on the Unix server the CPU of the workstations go to 100% usage resulting that the system gets very slow. The programm well its running so... (2 Replies)
Discussion started by: zerocool
2 Replies
Login or Register to Ask a Question