Thread: why this error is occuring what's wrong in my script??
here screen shot of both script , output don't it?? can tell me
, directories mentioned in script exist in system??
scriptcode:#!/bin/bash #only sudo can run script root_uid=0 #since users $uid 0 have root privileges e_notroot=87 #non-root exit error if [ "$uid" -ne "$root_uid" ]; echo "you must root run script" exit $e_notroot fi echo "enter username" read uname if grep -q "^$uname:" /etc/passwd; cd /home/$uname/projects echo "the files in directory are" ls else echo "incorrect username" fi echo "enter file name" read fname unzip $fname /home/krishna/desktop/test
you have written bash script; know because on line 1 have put
by typing "sh test.sh" trying run sh script. sh not bash. may work bash scripts because bash scripts sh scripts. doesn't work in case because uid variable set bash shell. not set sh shell.code:#!/bin/bash
unzip command means this: search zip archive file /home/krishna/desktop/test , extract it. unzip warns cannot find file in zip archive.
if intend extract archive directory /home/krishna/desktop/test need use -d as have been shown.
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk why this error is occuring what's wrong in my script??
Ubuntu
Comments
Post a Comment