Powered by Invision Power Board


  Reply to this topicStart new topicStart Poll

> programm name with command
bozzuul
Posted: May 6 2005, 08:38 PM
Quote Post


Newbie
*

Group: Members
Posts: 2
Member No.: 978
Joined: 6-May 05



How do I make an csh script with a command as variable.

example:

the programm name is hp

in the prompt i type hp 12345

now there must be a new directory 12345 in folder /home/user with the mkdir command.

12345 is the variable. The programm must work on each number of 5 digits.

regards,

bozzuul

PMEmail Poster
Top
bozzuul
  Posted: May 9 2005, 07:45 PM
Quote Post


Newbie
*

Group: Members
Posts: 2
Member No.: 978
Joined: 6-May 05



#!/bin/sh

cd /home/jan
mkdir $1


PMEmail Poster
Top
andyb1ack
Posted: May 10 2005, 04:24 PM
Quote Post


User Level: 4
****

Group: Members
Posts: 98
Member No.: 513
Joined: 9-September 04



Hi bozzul,

Bit dangerous. what if /home/jan doesn't exist? It'll create your directory where-ever you happen to be.

You can check the directory is there in the korn shell with:
CODE

if [[ ! -d ${DIR} ]]; then
 echo "ERROR: Directory ${DIR} does not exist"
 exit 10
fi
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
« Next Oldest | Shells & Scripting | Next Newest »

Topic Options Reply to this topicStart new topicStart Poll

 



[ Script Execution time: 0.0981 ]   [ 12 queries used ]   [ GZIP Enabled ]




Partners: Cambridge Plus :: <Link Available> :: PIC Boot-loader Utility :: <Link Available>
Unix Man Pages / Linux Man Pages :: HiFi Forum :: SIP VoIP Phone & Provider Reviews :: UNIX/Linux Forum Archives

More info on advertising on Unix/Linux Forum