Skip to main content

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??

script
code:
 #!/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
attached images attached images
  • file type: jpg s.jpg (82.4 kb, 14 views)

you have written bash script; know because on line 1 have put
code:
#!/bin/bash
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.

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

Popular posts from this blog

Could not place because the source rectangle is empty

Thread: Using smartcard reader with vpnc

Adobe Font Folio 7.0 or just 7?